Skip to content

Update version import. #15

Update version import.

Update version import. #15

# GitHub action for building the distribution and wheels of the sep package
# and uploading them to the PyPI package index.
name: build-wheels-upload-pypi
on: [push, workflow_dispatch]
# push:
# # Run this action on the trigger event when *any* tag is pushed
# tags:
# - '*'
jobs:
# This action is split into three jobs:
# - Building the source distribution
# - Building the wheels for the distribution
# - Uploading the artifacts to PyPI package
# The first and second job run in parallel.
# The uploading jos needs to have the other two finished without error.
# From now on, we run the tests before continuing with these jobs.
run_tests:
uses: ./.github/workflows/python-package-tox.yml
build_sdist:
needs: [run_tests]
# First the source distribution is done on ubuntu. This is not related
# to any operating system, so we could do it on the default os.
runs-on: ubuntu-24.04
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: install_python
uses: actions/setup-python@v5
with:
python-version: '3.12'
# For the build, sep needs numpy and cython and we add twine and wheel
# for better testing and checking.
- name: Install dependencies
run: python -m pip install setuptools twine numpy wheel cython build
- name: Build sdist
run: python -m build --sdist
- name: Show files
run: ls -lh dist
shell: bash
- name: Check metadata
run: twine check dist/*
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*.tar.gz
build_wheels:
needs: [run_tests]
# Second the wheels are build for different OS and python versions. This is
# done with the help of the `cibuildwheel` package.
#
# The wheels are built for Windows, Linux and MacOS and the python versions
# 3.9 - 3.13.
#
# The three operating system could be done in parallel.
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
strategy:
max-parallel: 4
matrix:
python-version: ["3.12"]
os: [windows-latest, macos-latest, ubuntu-24.04, ubuntu-24.04-arm]
steps:
- uses: actions/checkout@v4
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
CIBW_BUILD_VERBOSITY: 1
CIBW_SKIP: '*-musllinux_*'
CIBW_ARCHS_LINUX: "auto"
- name: Show files
run: ls -lh wheelhouse
shell: bash
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}
path: ./wheelhouse/*.whl
upload_to_pypi:
# Finally we collect all out data from the artifacts and put them back to
# dist directory for upload. The final step waits for the other jobs to be
# finished and starts only if the trigger event of the action was a push
# of a tag starting with <v> as version separation. All other jobs run
# without heading <v>
runs-on: [ubuntu-latest]
needs: [build_wheels, build_sdist]
environment:
name: pypi
url: https://pypi.org/p/sep
permissions:
id-token: write
# upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
steps:
- uses: actions/setup-python@v5
- uses: actions/download-artifact@v4
with:
pattern: dist*
merge-multiple: true
path: dist
- name: upload_to_pypi
uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/