Build and Publish #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish | |
on: | |
- workflow_dispatch | |
- workflow_call | |
jobs: | |
build_wheels: | |
needs: test_source | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
cibw_archs: auto64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD_FRONTEND: build | |
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.6" | |
CIBW_SKIP: "pp* *musllinux*" | |
CIBW_ARCHS: ${{ matrix.cibw_archs }} | |
CIBW_TEST_COMMAND: cd {project}/ && python tests/basic.py | |
with: | |
package-dir: ./ | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheels | |
path: ./wheelhouse/*.whl | |
test_source: | |
uses: ./.github/workflows/unittest.yml | |
build_sdist: | |
needs: test_source | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build sdist | |
run: make sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: sdist | |
path: ./dist/*.tar.gz | |
publish_test: | |
needs: [build_wheels, build_sdist] | |
name: Publish package to TestPyPI | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment | |
environment: release | |
# https://github.com/pypa/gh-action-pypi-publish#trusted-publishing | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: sdist | |
path: dist | |
- uses: actions/download-artifact@v4 | |
with: | |
name: wheels | |
path: dist | |
- name: Display structure of downloaded files | |
run: ls -R dist | |
- name: Publish package distributions to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ | |
publish_prod: | |
needs: [publish_test] | |
name: Publish package to PyPI | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: sdist | |
path: dist | |
- uses: actions/download-artifact@v4 | |
with: | |
name: wheels | |
path: dist | |
- name: Display structure of downloaded files | |
run: ls -R dist | |
- name: Publish package distributions to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} |