Skip to content

Commit

Permalink
Split up CI to separate test/publish workflows for simplicity.
Browse files Browse the repository at this point in the history
Also only rebuild documentation upon creating a new tag.
  • Loading branch information
LTLA committed Dec 9, 2024
1 parent d78ad86 commit a281c02
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 70 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Build documentation

on:
push:
branches:
- master
tags:
- '*'

jobs:
test:
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Publish to PyPI

on:
push:
tags:
- "*"

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, higher macos's are apple silicon
# At some point, maybe get this to work on windows-latest
os: [ubuntu-latest, macos-13, macos-latest]

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
CIBW_SKIP: pp*

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
69 changes: 1 addition & 68 deletions .github/workflows/pypi-test.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Test the library

on:
push:
branches:
- master
tags:
- "*"
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]

name: Python ${{ matrix.python-version }}
steps:
Expand All @@ -37,65 +32,3 @@ jobs:
run: |
pip install tox
tox
build_wheels:
name: Build wheels on ${{ matrix.os }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, higher macos's are apple silicon
# At some point, maybe get this to work on windows-latest
os: [ubuntu-latest, macos-13, macos-latest]

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
CIBW_SKIP: pp*

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
needs: [test, build_wheels, build_sdist]
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}

0 comments on commit a281c02

Please sign in to comment.