Merge pull request #297 from glotzerlab/dependabot-pip-dot-github-tru… #739
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: PyPI | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
# Trigger on pull requests. | |
pull_request: | |
# Trigger on pushes to the mainline branches and version tags. This prevents building commits | |
# twice when the pull request source branch is in the same repository. | |
push: | |
branches: | |
- "trunk-patch" | |
- "trunk-minor" | |
- "trunk-major" | |
tags: | |
- "v*" | |
# Trigger on request. | |
workflow_dispatch: | |
jobs: | |
build_wheels: | |
name: Build wheels [py${{ matrix.python_version }}, ${{ matrix.os }}] | |
runs-on: ${{ matrix.os }}-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu, windows, macos] | |
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/[email protected] | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_PROJECT_REQUIRES_PYTHON: "==${{ matrix.python_version }}.*" | |
- uses: actions/[email protected] | |
with: | |
name: dist | |
path: ./wheelhouse/*.whl | |
build_sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- uses: actions/[email protected] | |
name: Install Python | |
with: | |
python-version: '3.11' | |
- uses: actions/[email protected] | |
with: | |
path: ~/.cache/pip | |
key: gsd-build-wheels-pip-${{ hashFiles('.github/requirements-build-sdist.txt') }} | |
restore-keys: | | |
gsd-build-wheels-pip- | |
- name: Install build | |
run: python3 -m pip --disable-pip-version-check install -r .github/requirements-build-sdist.txt --progress-bar=off | |
- name: Build sdist | |
run: python -m build --sdist --outdir dist/ . | |
- uses: actions/[email protected] | |
with: | |
name: dist | |
path: dist/*.tar.gz | |
upload_pypi: | |
name: Publish [PyPI] | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifacts | |
uses: actions/[email protected] | |
with: | |
name: 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/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
- name: Upload to TestPyPI | |
# otherwise, upload to TestPyPi | |
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/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ | |
skip-existing: true |