Skip to content

Merge pull request #394 from glotzerlab/dependabot-github_actions-tru… #132

Merge pull request #394 from glotzerlab/dependabot-github_actions-tru…

Merge pull request #394 from glotzerlab/dependabot-github_actions-tru… #132

Workflow file for this run

name: PyPI
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
push:
branches:
- "trunk-*"
tags:
- "v*"
workflow_dispatch:
jobs:
build_wheels:
name: Build wheels [${{ matrix.python.version }}, ${{ matrix.os.base }}-${{ matrix.os.arch }}]
runs-on: ${{ matrix.os.base }}-${{ matrix.os.version }}
strategy:
fail-fast: false
matrix:
os:
- base: ubuntu
version: latest
arch: 'x86_64'
- base: windows
version: latest
arch: 'amd64'
- base: macos
version: 14
arch: 'arm64'
- base: macos
version: 13
arch: 'x86_64'
python:
- version: 'cp310'
oldest_numpy: '1.21.6'
- version: 'cp311'
oldest_numpy: '1.23.2'
- version: 'cp312'
oldest_numpy: '1.26.2'
- version: 'cp313'
oldest_numpy: '2.1.1'
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Build wheels
uses: pypa/cibuildwheel@d4a2945fcc8d13f20a1b99d461b8e844d5fc6e23 # v2.21.1
env:
CIBW_BUILD: "${{ matrix.python.version }}-*"
CIBW_TEST_REQUIRES: pytest==8.2.1 numpy==${{ matrix.python.oldest_numpy }}
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: dist-python-${{ matrix.python.version }}-${{ matrix.os.base }}-${{ matrix.os.arch }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: 3.12
- name: Set up Python environment
uses: glotzerlab/workflows/setup-uv@ae7e7c6931098a313ef8069ef04b88a55c3a40f6 # 0.3.0
with:
lockfile: ".github/requirements-build-sdist.txt"
- name: Build sdist
run: python -m build --sdist --outdir dist/ .
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: dist-sdist
path: dist/*.tar.gz
upload_pypi:
name: Publish [PyPI]
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
merge-multiple: 'true'
pattern: dist-*
path: dist
- name: Check files
run: ls -lR dist
- name: Upload to PyPI
# upload to PyPI on every tag starting with 'v'
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@897895f1e160c830e369f9779632ebc134688e1b # v1.10.2
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Upload to TestPyPI
# otherwise, upload to TestPyPi
continue-on-error: true
if: ${{ !startsWith(github.ref, 'refs/tags/v') && (github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) }}
uses: pypa/gh-action-pypi-publish@897895f1e160c830e369f9779632ebc134688e1b # v1.10.2
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true