Skip to content

Commit

Permalink
Add job to build wheels on new release (#209)
Browse files Browse the repository at this point in the history
* add ci jobs building/saving wheels and sdist, and distribution only on new release
  • Loading branch information
tmichela committed Jul 30, 2024
1 parent 5b37213 commit 9e7914f
Showing 1 changed file with 53 additions and 15 deletions.
68 changes: 53 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: |
Expand All @@ -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

0 comments on commit 9e7914f

Please sign in to comment.