Skip to content

Commit

Permalink
Refactor GitHub Actions workflow to improve package build and publish…
Browse files Browse the repository at this point in the history
… steps
  • Loading branch information
cleder committed Dec 5, 2024
1 parent df5310b commit 462ebd0
Showing 1 changed file with 60 additions and 26 deletions.
86 changes: 60 additions & 26 deletions .github/workflows/run-all-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,39 +124,73 @@ jobs:
run: |
pytest tests --ignore=tests/hypothesis
publish:
if: "github.event_name == 'push' && github.repository == 'cleder/pygeoif'"
needs: [cpython, static-tests, pypy, hypothesis-tests]
name: Build and publish to PyPI and TestPyPI
build-and-check-package:
name: Build & inspect our package.
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v4
- uses: hynek/build-and-inspect-python-package@v2
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- uses: hynek/build-and-inspect-python-package@v2
- uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Check with pyroma
run: |
uv tool run pyroma .
- name: Check tag name
if: >-
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags')
run: |
uv tool run vercheck $GITHUB_REF_NAME pygeoif/about.py
test-publish:
if: >-
github.event_name == 'push' &&
github.repository == 'cleder/pygeoif' &&
startsWith(github.ref, 'refs/tags')
needs: [build-and-check-package, pypy, test-coverage, hypothesis-tests, cpython, static-tests]
name: Test install on TestPyPI
runs-on: ubuntu-latest
environment: test-release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
- name: Download packages built by build-and-check-package
uses: actions/download-artifact@v4
with:
python-version: 3.12
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
- name: Publish distribution 📦 to Test PyPI for tags
if: startsWith(github.ref, 'refs/tags')
name: Packages
path: dist

- name: Upload package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/

publish:
if: >-
github.event_name == 'push' &&
github.repository == 'cleder/pygeoif' &&
github.ref == 'refs/heads/main'
needs: [build-and-check-package, pypy, test-coverage, hypothesis-tests, cpython, static-tests]
name: Publish to PyPI
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- name: Download packages built by build-and-check-package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- name: Publish distribution 📦 to PyPI for push to main
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: pypa/gh-action-pypi-publish@release/v1

...

0 comments on commit 462ebd0

Please sign in to comment.