From 21b1506484b72ac50610fbac8315e3c4d58f4400 Mon Sep 17 00:00:00 2001 From: Mark Parker <34688010+MarkParker5@users.noreply.github.com> Date: Thu, 22 Oct 2026 23:46:18 +0200 Subject: [PATCH] Publish to PyPI from the release workflow --- .github/workflows/release.yml | 26 ++++++++++++++++++++++++++ README.md | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5af89ec..8ae8d2b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,12 @@ name: Release on: workflow_dispatch: +# The reusable release workflow needs write (bump/merge/tag/release) + OIDC. A reusable workflow +# can't exceed the caller's grant, so grant it here, otherwise the run fails at startup. +permissions: + contents: write + id-token: write + jobs: release: uses: ParkerIndustries/workflows/.github/workflows/release.yml@v1 @@ -28,3 +34,23 @@ jobs: # If this project publishes docs, set docs-url to add "New/Updated Documentation" # sections (linking changed docs/**.md pages) to the release changelog: # docs-url: https://your-project.example.com + + # PyPI publish runs HERE, in the caller — Trusted Publishing can't match a reusable workflow. + publish-pypi: + name: Publish to PyPI + needs: release + runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/p/project-template + permissions: + id-token: write + steps: + - name: Download distributions + uses: actions/download-artifact@v8 + with: + pattern: dist-* + merge-multiple: true + path: dist/ + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/README.md b/README.md index e9c40d3..9e21dea 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ then: **1. Rename the placeholders** (two tokens — find & replace across the repo) - `project-template` → your PyPI/distribution name (hyphens): in `pyproject.toml` - (`[project].name`), `.github/workflows/release.yml` (`pypi-package-name`), and `mkdocs.yml`. + (`[project].name`), `.github/workflows/release.yml` (`pypi-package-name` and the publish job's PyPI `url`), and `mkdocs.yml`. - `project_template` → your import/package name (underscores): the `project_template/` directory, plus its `--cov=` / `packages` / `pythonpath` references in `pyproject.toml`. - If not publishing docs, delete `mkdocs.yml`, `docs/`, and `.github/workflows/docs.yml`;