From 78b3fbbea03b47bb11a0c185ab8b5e2d3e131d55 Mon Sep 17 00:00:00 2001 From: Tom Pollard Date: Wed, 2 Dec 2026 11:30:18 -0500 Subject: [PATCH] Allow manual publication of an existing release tag --- .github/workflows/publish.yml | 37 +++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 604b0311..6f33e50f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,8 +2,8 @@ name: Publish # Build the package from a published GitHub release and upload it to PyPI with # Trusted Publishing, which also uploads provenance attestations for the -# files. On a pull request that changes this file, or when run by hand, only -# build the package, without uploading anything. +# files. On a pull request that changes this file, only build the package. A +# manual run can publish an existing release tag if the release event is missed. # # One-time setup: # - On PyPI, in the wfdb project's settings, under Publishing, add a GitHub @@ -19,6 +19,11 @@ on: paths: - .github/workflows/publish.yml workflow_dispatch: + inputs: + release_tag: + description: Existing release tag to publish (for example, v5.15.0) + required: true + type: string permissions: contents: read @@ -29,16 +34,36 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: + - name: Check that the release is published + if: github.event_name == 'workflow_dispatch' + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + RELEASE_TAG: ${{ inputs.release_tag }} + run: | + draft=$(gh release view "$RELEASE_TAG" --json isDraft --jq .isDraft) + if [ "$draft" != false ]; then + echo "::error::The release $RELEASE_TAG is still a draft" + exit 1 + fi + - uses: actions/checkout@v7 + if: github.event_name == 'workflow_dispatch' + with: + persist-credentials: false + ref: refs/tags/${{ inputs.release_tag }} - uses: actions/checkout@v7 + if: github.event_name != 'workflow_dispatch' with: persist-credentials: false - uses: astral-sh/setup-uv@v10.4.0 - name: Check that the release tag matches the version - if: github.event_name == 'release' + if: github.event_name != 'pull_request' + env: + RELEASE_TAG: ${{ inputs.release_tag || github.ref_name }} run: | version=$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])') - if [ "$GITHUB_REF_NAME" != "v$version" ]; then - echo "::error::The release tag $GITHUB_REF_NAME does not match version $version in pyproject.toml" + if [ "$RELEASE_TAG" != "v$version" ]; then + echo "::error::The release tag $RELEASE_TAG does not match version $version in pyproject.toml" exit 1 fi - name: Build @@ -51,7 +76,7 @@ jobs: publish: name: Upload to PyPI - if: github.event_name == 'release' + if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' needs: build runs-on: ubuntu-latest timeout-minutes: 10