From 5bd9b6e70a0893b5e4e5f0d290d3c51fe8722b5d Mon Sep 17 00:00:00 2001 From: Matt Lewellyn Date: Mon, 16 Nov 2026 12:37:18 -0500 Subject: [PATCH] add pypi publish workflow --- .github/workflows/pypi.yaml | 58 +++++++++++++++++++++++++++++++++++++ noxfile.py | 11 ++----- 2 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/pypi.yaml diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml new file mode 100644 index 0000000..9de13ea --- /dev/null +++ b/.github/workflows/pypi.yaml @@ -0,0 +1,58 @@ +name: PyPI publish + +on: + pull_request: + paths: + - '.github/workflows/pypi.yaml' + push: + tags: + - 'v*.*.*' + + +jobs: + build: + name: Build and validate distributions + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - name: Build and validate wheel and sdist + uses: level12/coppy/gh-actions/nox-run@main + env: + PALS_DIST_DIR: dist + with: + nox-session: build + + - name: Upload validated distributions + uses: actions/upload-artifact@v4 + with: + name: release-dists + path: dist/ + if-no-files-found: error + + publish: + name: Publish distributions to PyPI + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: build + runs-on: ubuntu-latest + + environment: + name: pypi-publish + url: https://pypi.org/p/pals + + permissions: + id-token: write + + steps: + - name: Download validated distributions + uses: actions/download-artifact@v5 + with: + name: release-dists + path: dist/ + + - name: Publish distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: dist/ diff --git a/noxfile.py b/noxfile.py index 140e37c..b552b40 100644 --- a/noxfile.py +++ b/noxfile.py @@ -40,8 +40,8 @@ def audit(session: nox.Session): @nox.session def build(session: nox.Session): - uv_sync(session, 'build', 'pytest') - output_dir = Path(session.create_tmp()) / 'dist' + uv_sync(session, 'build') + output_dir = Path(environ.get('PALS_DIST_DIR', Path(session.create_tmp()) / 'dist')) session.run('python', '-m', 'build', '--outdir', output_dir) session.run('twine', 'check', *output_dir.glob('*')) (wheel_path,) = output_dir.glob('*.whl') @@ -58,12 +58,7 @@ def build(session: nox.Session): session.run( 'python', '-c', - 'import pals; print(f"Testing installed wheel at {pals.__file__}")', - ) - session.run( - 'pytest', - '-q', - package_path / 'tests/pals_tests/test_core.py::TestLocker', + 'import pals; print(f"Imported installed wheel from {pals.__file__}")', )