-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add job to build wheels on new release (#209)
* add ci jobs building/saving wheels and sdist, and distribution only on new release
- Loading branch information
Showing
1 changed file
with
53 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,13 @@ name: Tests | |
on: | ||
push: | ||
branches: [ master ] | ||
tags: [ '*' ] | ||
pull_request: | ||
release: | ||
types: | ||
- published | ||
|
||
env: | ||
PIP_CONSTRAINT: "${{ github.workspace }}/.github/dependabot/constraints.txt" | ||
|
||
jobs: | ||
tests: | ||
|
@@ -31,7 +36,7 @@ jobs: | |
- name: Install dependencies | ||
# Note that we do an editable install so that coverage can look at the files in src/ | ||
run: | | ||
python3 -m pip install -e .[test] --constraint .github/dependabot/constraints.txt | ||
python3 -m pip install -e .[test] | ||
- name: Test with pytest | ||
run: | | ||
|
@@ -46,26 +51,59 @@ jobs: | |
token: ${{ secrets.CODECOV_TOKEN }} | ||
verbose: true | ||
|
||
publish: | ||
build_wheels: | ||
name: Build wheels | ||
runs-on: ubuntu-latest | ||
if: ${{ startsWith(github.ref, 'refs/tags/') }} | ||
needs: tests | ||
permissions: | ||
id-token: write # OIDC for uploading to PyPI | ||
if: github.event_name == 'release' && github.event.action == 'published' | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
env: | ||
CIBW_BUILD: cp310-* | ||
CIBW_SKIP: "*-musllinux_* pp*" | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheels | ||
path: ./wheelhouse/*.whl | ||
|
||
build_sdist: | ||
name: Build source distribution | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'release' && github.event.action == 'published' | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build sdist | ||
run: pipx run build --sdist | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v4 | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
python-version: "3.10" | ||
name: sdist | ||
path: dist/*.tar.gz | ||
|
||
publish: | ||
name: Publish release to PyPI | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'release' && github.event.action == 'published' | ||
needs: [tests, build_wheels, build_sdist] | ||
permissions: | ||
id-token: write # OIDC for uploading to PyPI | ||
|
||
- name: Build packages | ||
run: | | ||
python3 -m pip install build | ||
python3 -m build | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: dist | ||
merge-multiple: true | ||
|
||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |