From 1d8ee19cfc06da8dfb72532a801f9dc028807192 Mon Sep 17 00:00:00 2001 From: mignot Date: Wed, 2 Dec 2026 19:46:11 +0100 Subject: [PATCH 1/4] feat(release-tag): recover a release whose main push produced no run A release tag only exists if a push run saw before..after. When GitHub creates no run, nothing can be re-run and release-please stays blocked. Callers can now dispatch the release-commit input, which replays parent..commit through the same validation. Refs #107 Co-Authored-By: Claude Sonnet 5.5 --- .github/tests/check-concurrency.sh | 23 +++++++ .github/workflows/publish-python.yml | 21 +++++-- .github/workflows/release-please.yml | 11 +++- .github/workflows/release-tag.yml | 25 ++++++-- CONTRIBUTING.md | 2 +- README.md | 32 +++++++--- conformance/check-concurrency.sh | 12 +++- examples/release-please-python.yml | 10 ++- examples/release-please.yml | 9 ++- examples/release-tag.yml | 9 ++- release/reconcile-release-prs.py | 13 +++- release/release-range.py | 48 ++++++++++++++ release/test_reconcile_release_prs.py | 11 ++++ release/test_release_range.py | 91 +++++++++++++++++++++++++++ 14 files changed, 285 insertions(+), 32 deletions(-) create mode 100644 release/release-range.py create mode 100644 release/test_release_range.py diff --git a/.github/tests/check-concurrency.sh b/.github/tests/check-concurrency.sh index a0b366e..114f52e 100755 --- a/.github/tests/check-concurrency.sh +++ b/.github/tests/check-concurrency.sh @@ -131,6 +131,29 @@ both "event form through an event exemption" 0 "ok r" exemptions r '{"concurrency":{"exemptions":[{"workflow":"release.yml","form":"queue","reason":"deploys"}]}}' both "sha group on a queue exemption is rejected" 1 "expected queue form" +recovery_workflow() { # + reset + workflow r release.yml <&2; exit 1; } test "$WORKFLOW_REPOSITORY" = BehindTheMusicTree/github-workflows echo "sha=$WORKFLOW_SHA" >> "$GITHUB_OUTPUT" - - name: Require a main push, a release tag and a known registry + - name: Require a main push or release-commit dispatch, a release tag and a known registry env: EVENT: ${{ github.event_name }} REF: ${{ github.ref }} DELETED: ${{ github.event.deleted }} + RELEASE_COMMIT: ${{ github.event.inputs.release-commit }} RELEASE_TAG: ${{ inputs.release-tag }} REGISTRY: ${{ inputs.registry }} run: | - test "$EVENT" = push test "$REF" = refs/heads/main - test "$DELETED" = false + case "$EVENT" in + push) test "$DELETED" = false; test -z "$RELEASE_COMMIT" ;; + workflow_dispatch) test -n "$RELEASE_COMMIT" || { echo 'release-commit input missing' >&2; exit 1; } ;; + *) echo "Unsupported event: $EVENT" >&2; exit 1 ;; + esac test -n "$RELEASE_TAG" || { echo 'release-tag is empty: no release tag was created in this run' >&2; exit 1; } case "$REGISTRY" in pypi|testpypi) ;; @@ -97,13 +101,18 @@ jobs: auth="$(printf 'x-access-token:%s' "$GITHUB_TOKEN" | base64 -w0 2>/dev/null || printf 'x-access-token:%s' "$GITHUB_TOKEN" | base64)" echo "::add-mask::$auth" # A tag just created through the API can take a moment to be served by git. + fetched=false for attempt in 1 2 3 4 5 6; do - git -c "http.extraheader=AUTHORIZATION: basic $auth" fetch --no-tags origin "+refs/tags/$RELEASE_TAG:refs/tags/$RELEASE_TAG" && exit 0 + if git -c "http.extraheader=AUTHORIZATION: basic $auth" fetch --no-tags origin "+refs/tags/$RELEASE_TAG:refs/tags/$RELEASE_TAG"; then + fetched=true + break + fi echo "Tag $RELEASE_TAG not yet fetchable (attempt $attempt/6)" >&2 sleep 5 done - echo "Tag $RELEASE_TAG could not be fetched" >&2 - exit 1 + [ "$fetched" = true ] || { echo "Tag $RELEASE_TAG could not be fetched" >&2; exit 1; } + # A dispatched recovery runs on main's HEAD; build the tagged commit. + git checkout --quiet --detach "refs/tags/$RELEASE_TAG^{commit}" - uses: actions/checkout@v5 with: repository: BehindTheMusicTree/github-workflows diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 78434ab..4a705a3 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -51,15 +51,19 @@ jobs: run: | [[ "$WORKFLOW_SHA" =~ ^[0-9a-f]{40}$ ]] || { echo 'Workflow commit SHA unavailable' >&2; exit 1; } test "$WORKFLOW_REPOSITORY" = BehindTheMusicTree/github-workflows || { echo 'Unexpected workflow repository' >&2; exit 1; } - - name: Require a main push + - name: Require a main push or a main release-commit dispatch env: EVENT: ${{ github.event_name }} REF: ${{ github.ref }} DELETED: ${{ github.event.deleted }} + RELEASE_COMMIT: ${{ github.event.inputs.release-commit }} run: | - test "$EVENT" = push test "$REF" = refs/heads/main - test "$DELETED" = false + case "$EVENT" in + push) test "$DELETED" = false; test -z "$RELEASE_COMMIT" ;; + workflow_dispatch) test -n "$RELEASE_COMMIT" || { echo 'release-commit input missing' >&2; exit 1; } ;; + *) echo "Unsupported event: $EVENT" >&2; exit 1 ;; + esac - name: Require App configuration env: APP_ID: ${{ inputs.app-id }} @@ -98,6 +102,7 @@ jobs: env: RELEASE_PR_APP_TOKEN: ${{ steps.app.outputs.token }} POLICIES: ${{ inputs.release-policies }} + CALLER_WORKFLOW: ${{ github.workflow_ref }} run: | mapfile -t policies < <(grep '[^[:space:]]' <<< "$POLICIES" | sed -E 's/^[[:space:]]+|[[:space:]]+$//g') python3 ../foundation/release/reconcile-release-prs.py "${policies[@]}" diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml index 6778b1b..748d02b 100644 --- a/.github/workflows/release-tag.yml +++ b/.github/workflows/release-tag.yml @@ -42,15 +42,19 @@ jobs: run: | [[ "$WORKFLOW_SHA" =~ ^[0-9a-f]{40}$ ]] || { echo 'Workflow commit SHA unavailable' >&2; exit 1; } test "$WORKFLOW_REPOSITORY" = BehindTheMusicTree/github-workflows || { echo 'Unexpected workflow repository' >&2; exit 1; } - - name: Require a main push + - name: Require a main push or a main release-commit dispatch env: EVENT: ${{ github.event_name }} REF: ${{ github.ref }} DELETED: ${{ github.event.deleted }} + RELEASE_COMMIT: ${{ github.event.inputs.release-commit }} run: | - test "$EVENT" = push test "$REF" = refs/heads/main - test "$DELETED" = false + case "$EVENT" in + push) test "$DELETED" = false; test -z "$RELEASE_COMMIT" ;; + workflow_dispatch) test -n "$RELEASE_COMMIT" || { echo 'release-commit input missing' >&2; exit 1; } ;; + *) echo "Unsupported event: $EVENT" >&2; exit 1 ;; + esac - uses: actions/checkout@v5 with: ref: ${{ github.sha }} @@ -72,10 +76,19 @@ jobs: id: intent working-directory: caller env: - BEFORE: ${{ github.event.before }} - AFTER: ${{ github.sha }} + EVENT: ${{ github.event_name }} + PUSH_BEFORE: ${{ github.event.before }} + PUSH_AFTER: ${{ github.sha }} + RELEASE_COMMIT: ${{ github.event.inputs.release-commit }} POLICY: ${{ inputs.release-policy-path }} run: | + # Assign before reading: a process substitution would hide the script's exit status. + if [ "$EVENT" = workflow_dispatch ]; then + range=$(python3 ../foundation/release/release-range.py dispatch "$RELEASE_COMMIT") + else + range=$(python3 ../foundation/release/release-range.py push "$PUSH_BEFORE" "$PUSH_AFTER") + fi + read -r BEFORE AFTER <<< "$range" python3 ../foundation/release/validate-release.py "$BEFORE" "$AFTER" "$POLICY" > "$RUNNER_TEMP/release-intent.json" jq -r '"release=\(.release)", "tag=\(.tag // "")", "commit=\(.commit // "")", "github_release=\(.github_release // false)"' "$RUNNER_TEMP/release-intent.json" >> "$GITHUB_OUTPUT" @@ -84,7 +97,7 @@ jobs: if: needs.validate.outputs.release == 'true' runs-on: ubuntu-latest timeout-minutes: 5 - # Each event is independent: callers use a per-commit group (`-${{ github.sha }}`, no cancel); a ref-level group replaces a pending run and drops its bump. + # Each event is independent: callers use a per-commit group (`-${{ inputs.release-commit || github.sha }}`, no cancel); a ref-level group replaces a pending run and drops its bump. steps: - name: Require the caller-pinned workflow commit env: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 87a6058..80fda8a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -184,7 +184,7 @@ After opening the PR, maintainers will review and may request changes. Once appr Release Please prepares releases from conventional PR titles squash merged into `main`. Use `fix:` for a patch, `feat:` for a minor release, and `!` for a breaking change. Keep `CHANGELOG.md` and `VERSION` edits in the generated release PR. -The release caller sets `auto-merge: true`. GitHub squash merges the release PR once the required checks pass. The main-push workflow validates the version and changelog, creates the annotated tag on the squash commit, and publishes the GitHub Release. Rerun the original main-push workflow to recover from a tagging or publication failure. +The release caller sets `auto-merge: true`. GitHub squash merges the release PR once the required checks pass. The main-push workflow validates the version and changelog, creates the annotated tag on the squash commit, and publishes the GitHub Release. Rerun the original main-push workflow to recover from a tagging or publication failure; if the push produced no run at all, [dispatch the recovery](README.md#recovering-a-release-push-that-produced-no-run). #### Choosing the version diff --git a/README.md b/README.md index 5dbbdc2..d511b2f 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,11 @@ caller uses the limits defined by the workflow revision it references. [`publish-python.yml`](.github/workflows/publish-python.yml) builds exactly one wheel and one `.tar.gz` sdist from the caller's selected package directory (the repository root by default), checks their metadata, and uploads them with a SHA-256 manifest. It runs inside -the release run of a **push to `main`**, after a `release-tag.yml` job of the same run has -created the package's tag: pass that job's `tag` output as `release-tag`. The tag's -dereferenced commit must be the checked-out commit and descend from `origin/main`, the +the release run of a **push to `main`** (or of the dispatch that +[recovers one](#recovering-a-release-push-that-produced-no-run)), after a `release-tag.yml` +job of the same run has created the package's tag: pass that job's `tag` output as +`release-tag`. The workflow checks out and builds the tagged commit, which on a push is the +run's own commit. That commit must descend from `origin/main`, the selected release policy (default `.github/release-policy.json`) must be valid with matching canonical version/mirrors and populated release notes. Put the exact `package-name` in the policy's `outputs.packages` array. Only stable `X.Y.Z` versions are supported. @@ -143,7 +145,7 @@ conditions explicitly: release publishes nothing in the run (`needs.tag-graph.outputs.tag == ''`), so the step makes a single attempt: the pinned version is already public and a failure is real. -Use only the per-commit group `-${{ github.sha }}` with `cancel-in-progress: false`, as the +Use only the per-commit group `-${{ inputs.release-commit || github.sha }}` with `cancel-in-progress: false`, as the example does: a ref-level group replaces a pending run and drops its release bump. A registry visibility delay no longer needs a rerun (see the waits above); **Re-run failed jobs** is only for a real failure. It reruns `publish-graph` and its dependents with the same `job.workflow_sha`, and `prepare` uploads the files it does not @@ -217,6 +219,8 @@ Required organization check for every repository, run on push and pull request. | Event | `-${{ github.sha }}` | `false` | workflows in which any job calls a `release_workflows` entry of `rules.json` (the other jobs share its per-commit group); `event` exemptions | | Queue | `-${{ github.ref }}` | `false` | `queue` exemptions (deploys, publications) | + An event-form workflow that declares the `release-commit` `workflow_dispatch` input also accepts `-${{ inputs.release-commit || github.sha }}` (see [recovery](#recovering-a-release-push-that-produced-no-run)). Update the checker pin before adopting it. + The CI group uses the PR number for every pull request event, including `closed`, and the full ref for pushes. Org conformance also accepts `-${{ github.head_ref || github.ref }}` during the rollout. Update the checker pin before switching existing caller workflows to the new group. A workflow triggered only by `workflow_call` must not declare workflow-level concurrency: its callers do. @@ -662,7 +666,7 @@ A repository releasing several independent components (for example `v*` and `gra Use the [caller example](examples/release-tag.yml), replacing its placeholder with a full **merged and reviewed commit SHA**. Every `uses:` of `release-tag.yml`, `release-github.yml`, `release-please.yml` or `publish-python.yml` from this repository in the adopter's `.github/workflows/` must carry that same SHA: the validation job fails, before any tag exists, when one differs. Align pins in a single PR; a bump of the pin is a release-workflow change like any other. Configure `RELEASE_APP_ID` and the explicitly named `RELEASE_APP_PRIVATE_KEY` secret. Install the App on the adopting repository with Contents write permission; select only adopting repositories for organization secrets. Do not pass registry credentials or `secrets: inherit`. -Before enabling a caller, configure separate tag rulesets: creation permits the release App; update/deletion protection has no App bypass. The App must have no bypass of `main` protection. PR checks must cover the version and publisher changes before merge. If a repository also requires checks after merge, add those jobs in the caller's push workflow and make the reusable-workflow job depend on their successful completion with `needs`. Those checks must operate on `github.sha`, including reruns after a later push; a check of the latest branch tip is insufficient. +Before enabling a caller, configure separate tag rulesets: creation permits the release App; update/deletion protection has no App bypass. The App must have no bypass of `main` protection. PR checks must cover the version and publisher changes before merge. If a repository also requires checks after merge, add those jobs in the caller's push workflow and make the reusable-workflow job depend on their successful completion with `needs`. Those checks must operate on `inputs.release-commit || github.sha` (they must check out that ref, so that a [recovery dispatch](#recovering-a-release-push-that-produced-no-run) checks the release commit), including reruns after a later push; a check of the latest branch tip is insufficient. Activation and changes to the contract must land in a separate push from a version bump. Activation validates the current version, mirrors and changelog but never tags it, including an existing version with no tag. A subsequent push with no bump also produces no tag. For an established contract, a bump must increase the version and leave the policy unchanged; all mirrors and its changelog section must match. The version comparison uses the push's before/after commits, never the current branch tip. Force pushes and newly created branch events fail closed. @@ -672,13 +676,23 @@ Validation runs without App secrets and checks ancestry against fetched `origin/ Each run creates an annotated tag object, then atomically creates its ref, checking both write responses. Verification then re-reads the tag with backoff (about 23 seconds) because GitHub reads can briefly return 404 after a write; a mismatch fails immediately, and a tag still unreadable afterwards fails with a hint to rerun the job, which then reports an existing tag. An existing lightweight or annotated tag that dereferences to the same commit is a successful retry; a tag on another commit fails. Concurrent creation is accepted only after resolving the winner to the same SHA. API failures propagate. There is no global concurrency group that can discard a pending bump. A failed API response after ref creation can be retried with the same push event; never move a tag or bump again to recover. -`outputs` records the publisher contract; this tagger does not assert that those artifacts are published. For a partial publication, rerun the existing tag publisher after checking each required artifact. In a multi-package project the publisher must skip an already published identical version and distinguish registry errors from an absent package. GitHub Release creation must have one owner and wait for every required package. Do not replace a missing publisher run with an arbitrary workflow dispatch. +`outputs` records the publisher contract; this tagger does not assert that those artifacts are published. For a partial publication, rerun the existing tag publisher after checking each required artifact. In a multi-package project the publisher must skip an already published identical version and distinguish registry errors from an absent package. GitHub Release creation must have one owner and wait for every required package. Do not replace a missing publisher run with an arbitrary workflow dispatch; the tagger's [validated recovery dispatch](#recovering-a-release-push-that-produced-no-run) is the one supported way to replay a missing release run. Run `python3 -m unittest discover -s release -p 'test_*.py'`, `bash .github/scripts/tests/release.sh`, `shellcheck .github/scripts/release.sh .github/scripts/tests/release.sh`, and `actionlint`. Tests simulate tagging and API errors without credentials or remote writes. Python 3.11+ is required. Repository-specific publisher recovery and a live App run are adoption checks, beyond the local foundation tests. ### GitHub-only publisher and package recovery -**GitHub-only policies are published by `release-tag.yml` itself.** After the tag job, a `publish` job (same pinned commit) validates the tag and creates the GitHub Release when the policy declares `github_release: true` and no `packages`. A separate tag-triggered `publish.yml` is then unnecessary and should be deleted: it re-validated the changelog with its own pin, so a pin older than the tagging one could reject a tag that was already immutable (`exactly one versioned changelog section required`) with no way to recover. The caller job needs `permissions: contents: write` (GitHub checks it statically, even for policies that skip publication). Recovery is "Re-run failed jobs" on the push run, which keeps the same pin and treats an existing tag or release as success. Package policies keep their own publisher. +**GitHub-only policies are published by `release-tag.yml` itself.** After the tag job, a `publish` job (same pinned commit) validates the tag and creates the GitHub Release when the policy declares `github_release: true` and no `packages`. A separate tag-triggered `publish.yml` is then unnecessary and should be deleted: it re-validated the changelog with its own pin, so a pin older than the tagging one could reject a tag that was already immutable (`exactly one versioned changelog section required`) with no way to recover. The caller job needs `permissions: contents: write` (GitHub checks it statically, even for policies that skip publication). When the push run exists, recovery is "Re-run failed jobs" on it, which keeps the same pin and treats an existing tag or release as success; when GitHub created no run, use the [recovery dispatch](#recovering-a-release-push-that-produced-no-run). Package policies keep their own publisher. + +### Recovering a release push that produced no run + +A release tag only exists if a push run saw the release commit. If GitHub created no run for that push (for example during an Actions outage), there is nothing to re-run, the tag rulesets forbid a manual tag, and release-please fails reconciliation on the merged release PR, printing the command to run. Dispatch the caller workflow on `main` with the full SHA of the release commit: + +```sh +gh workflow run .yml --ref main -f release-commit= +``` + +The run replays the lost push: it validates the range `parent..commit` with the same release policies, using the workflow pins of `main`'s head, then tags and publishes that commit. It is idempotent: an existing tag or GitHub Release on the same commit counts as success, and a commit without a version bump releases nothing. The commit must have exactly one parent and be on the first-parent history of `main`, as every squash merge is. The caller needs the `workflow_dispatch` trigger and the concurrency group shown in the [examples](examples/release-please.yml). **Deprecated:** `release-github.yml`, and the pattern of a tag-push workflow that calls it, remain only for callers not yet migrated (currently `the-music-tree-pipelines`, `hear-the-music-tree-api` and `python-project-standards`); its pin must equal the tagging pin. New adopters use the [release-please callers](examples/release-please.yml). Removal is planned for a future major version, once those callers have migrated. @@ -714,13 +728,13 @@ publisher job and retain its npm OIDC configuration and runtime. Two Apps keep the duties apart: the tag App (`RELEASE_APP_ID`, Contents write, sole bypass of the tag-creation ruleset) and a preparation App (`RELEASE_PR_APP_ID` and the `RELEASE_PR_APP_PRIVATE_KEY` secret: Contents, Pull requests and Issues write, **no** ruleset bypass). Both are declared in `github-config`; an org admin creates and installs the preparation App. The tag rulesets must cover the prefix of every policy (for example `graph-v*`). -Each run first reconciles merged release PRs. `skip-github-release` leaves them labelled `autorelease: pending`, and release-please aborts every later run while one exists. [`release/reconcile-release-prs.py`](release/reconcile-release-prs.py) verifies, for each such merged PR, that it was squash merged into a single parent commit, that the release policies see a release on it, and that each expected tag exists on that exact commit, and that any GitHub Release declared by policy has been published. It then adds `autorelease: tagged` and removes `autorelease: pending`. Reconciliation fails if these checks fail. If a tag or GitHub Release is missing, let the release run finish or retry its failed jobs first. A later push to `main` may reach reconciliation while the preceding release is still publishing. The pending label prevents it from advancing the next release. Before adopting, relabel any stale merged release PR still carrying `autorelease: pending` (for example one merged before adoption or without a squash): reconciliation fails closed on it until it is handled by hand. +Each run first reconciles merged release PRs. `skip-github-release` leaves them labelled `autorelease: pending`, and release-please aborts every later run while one exists. [`release/reconcile-release-prs.py`](release/reconcile-release-prs.py) verifies, for each such merged PR, that it was squash merged into a single parent commit, that the release policies see a release on it, and that each expected tag exists on that exact commit, and that any GitHub Release declared by policy has been published. It then adds `autorelease: tagged` and removes `autorelease: pending`. Reconciliation fails if these checks fail. If a tag or GitHub Release is missing, let the release run finish or retry its failed jobs first; if the release push produced no run at all, [dispatch the recovery](#recovering-a-release-push-that-produced-no-run). A later push to `main` may reach reconciliation while the preceding release is still publishing. The pending label prevents it from advancing the next release. Before adopting, relabel any stale merged release PR still carrying `autorelease: pending` (for example one merged before adoption or without a squash): reconciliation fails closed on it until it is handled by hand. Adopting: 1. Commit `release-please-config.json` and `.release-please-manifest.json` ([config](examples/release-please-config.json), [manifest](examples/.release-please-manifest.json)) with the manifest at the current versions, and one release policy per component ([root](examples/release-policy.json), [graph](examples/graph-release-policy.json)). The `.` package uses `simple` with `version-file`, `include-component-in-tag: false` and `exclude-paths` for the other components. 2. Remove the `## [Unreleased]` section from each changelog: release-please inserts its section above it, which would leave the entries stranded below. -3. Replace the `release-tag.yml` caller by the [combined caller](examples/release-please.yml): one tagging job per policy, then `release-please` with `needs` on all of them, so tags exist before reconciliation. Pin every `uses` (including any remaining publisher) to the same merged commit SHA; `release-tag.yml` enforces it. When one component is a published Python package that another component installs from PyPI, use the [published-package variant](examples/release-please-python.yml) instead. +3. Replace the `release-tag.yml` caller by the [combined caller](examples/release-please.yml): one tagging job per policy, then `release-please` with `needs` on all of them, so tags exist before reconciliation. Keep its `workflow_dispatch` trigger with the `release-commit` input and its concurrency group `-${{ inputs.release-commit || github.sha }}`. Pin every `uses` (including any remaining publisher) to the same merged commit SHA; `release-tag.yml` enforces it. When one component is a published Python package that another component installs from PyPI, use the [published-package variant](examples/release-please-python.yml) instead. 4. Install the preparation App on the repository and set `RELEASE_PR_APP_ID` and `RELEASE_PR_APP_PRIVATE_KEY`. 5. Use squash merges with the PR title as the commit title, and conventional PR titles (`feat:`, `fix:`, `feat!:`): release-please ignores a non-conventional squash title. Merge the release PR with its title unchanged. diff --git a/conformance/check-concurrency.sh b/conformance/check-concurrency.sh index 1f8d942..7942f2c 100755 --- a/conformance/check-concurrency.sh +++ b/conformance/check-concurrency.sh @@ -9,6 +9,11 @@ # cancel-in-progress: ${{ github.event_name == 'pull_request' }} # Event form: group: -${{ github.sha }} # cancel-in-progress: false +# Recovery form: group: -${{ inputs.release-commit || github.sha }} +# cancel-in-progress: false +# Event form of a workflow that declares the `release-commit` workflow_dispatch input +# (recovery of a release push that produced no run). Keyed on the replayed commit, so a +# dispatch cannot replace the pending push run of main's head. # Queue form: group: -${{ github.ref }} # cancel-in-progress: false # With a ref group, GitHub keeps one pending run and replaces it with the next one. release-tag only @@ -127,6 +132,8 @@ def triggers: (.on // .["true"] // {}) | if type == "string" then [.] elif type == "array" then . elif type == "object" then keys else [] end; def ci_triggered: triggers | any(. == "push" or . == "pull_request"); def stem: sub("\\.ya?ml$"; ""); +def recovers: + (.on // .["true"] // {}) | objects | .workflow_dispatch | objects | .inputs | objects | has("release-commit"); def release_caller: any((.jobs // {})[]; (.uses // "" | sub("@.*$"; "")) as $u | ($rules.release_workflows | index($u)) != null); ($wfs[] as $w @@ -134,7 +141,10 @@ def release_caller: | if ($w.doc | ci_triggered) then ([$ex[] | select(.workflow == $w.file)][0]) as $x | (if ($w.doc | release_caller) or ($x != null and $x.form == "event") - then {kind: "event", groups: ["\($s)-${{ github.sha }}"], cancel: false} + then {kind: "event", + groups: ((if any($w.doc | recovers; .) then ["\($s)-${{ inputs.release-commit || github.sha }}"] else [] end) + + ["\($s)-${{ github.sha }}"]), + cancel: false} elif $x != null then {kind: "queue", groups: ["\($s)-${{ github.ref }}"], cancel: false} else {kind: "CI", diff --git a/examples/release-please-python.yml b/examples/release-please-python.yml index 9455bd9..02bf0c2 100644 --- a/examples/release-please-python.yml +++ b/examples/release-please-python.yml @@ -9,11 +9,18 @@ name: Release on: push: branches: [main] + # Recovery when GitHub created no run for a release push: replays that push's validation on the given commit. + workflow_dispatch: + inputs: + release-commit: + description: Full SHA of the release commit on main whose push produced no run + type: string + required: true permissions: contents: read # One run per pushed commit, never cancelled or replaced: release-tag validates only before..after, so a replaced run would leave its bump untagged. concurrency: - group: release-${{ github.sha }} + group: release-${{ inputs.release-commit || github.sha }} cancel-in-progress: false # Keep this per-commit group: a ref-level group would replace a pending run and drop its release bump. # Recover from a failed job with "Re-run failed jobs"; prepare only uploads the files still missing, and verify @@ -90,6 +97,7 @@ jobs: steps: - uses: actions/checkout@v5 with: + ref: ${{ inputs.release-commit || github.sha }} persist-credentials: false - uses: actions/setup-python@v6 with: diff --git a/examples/release-please.yml b/examples/release-please.yml index 056266c..6130ef7 100644 --- a/examples/release-please.yml +++ b/examples/release-please.yml @@ -5,11 +5,18 @@ name: Release on: push: branches: [main] + # Recovery when GitHub created no run for a release push: replays that push's validation on the given commit. + workflow_dispatch: + inputs: + release-commit: + description: Full SHA of the release commit on main whose push produced no run + type: string + required: true permissions: contents: read # One run per pushed commit, never cancelled or replaced: release-tag validates only before..after, so a replaced run would leave its bump untagged. concurrency: - group: release-please-${{ github.sha }} + group: release-please-${{ inputs.release-commit || github.sha }} cancel-in-progress: false jobs: tag-root: diff --git a/examples/release-tag.yml b/examples/release-tag.yml index 9482e40..464129c 100644 --- a/examples/release-tag.yml +++ b/examples/release-tag.yml @@ -4,11 +4,18 @@ name: Release tag on: push: branches: [main] + # Recovery when GitHub created no run for a release push: replays that push's validation on the given commit. + workflow_dispatch: + inputs: + release-commit: + description: Full SHA of the release commit on main whose push produced no run + type: string + required: true permissions: contents: read # One run per pushed commit, never cancelled or replaced: release-tag validates only before..after, so a replaced run would leave its bump untagged. concurrency: - group: release-tag-${{ github.sha }} + group: release-tag-${{ inputs.release-commit || github.sha }} cancel-in-progress: false jobs: release: diff --git a/release/reconcile-release-prs.py b/release/reconcile-release-prs.py index 2ee28fe..b6d7783 100644 --- a/release/reconcile-release-prs.py +++ b/release/reconcile-release-prs.py @@ -50,7 +50,13 @@ def release_commit(pull): return fields[1], sha -def reconcile(api, policy_paths): +def recovery_hint(commit, caller_workflow): + # caller_workflow is github.workflow_ref: owner/repo/.github/workflows/@ + workflow = caller_workflow.split('@', 1)[0].rsplit('/', 1)[-1] if caller_workflow else '' + return f'gh workflow run {workflow} --ref main -f release-commit={commit}' + + +def reconcile(api, policy_paths, caller_workflow=None): if not policy_paths: raise ValueError('At least one release policy is required') done = [] @@ -69,7 +75,8 @@ def reconcile(api, policy_paths): raise ValueError(f'PR #{number} carries no release intent for the given policies') for tag, github_release in outputs: if TAGGING['existing_commit'](api, tag) != commit: - raise ValueError(f'Tag {tag} of PR #{number} is missing or targets another commit') + raise ValueError(f'Tag {tag} of PR #{number} is missing or targets another commit; if no run of its ' + f'main push exists, recover with: {recovery_hint(commit, caller_workflow)}') if github_release: try: release = api.request('GET', '/releases/tags/' + quote(tag, safe='')) @@ -91,7 +98,7 @@ def reconcile(api, policy_paths): def main(): api = GitHub(os.environ['GITHUB_REPOSITORY'], os.environ['RELEASE_PR_APP_TOKEN'], os.environ['GITHUB_API_URL']) - done = reconcile(api, sys.argv[1:]) + done = reconcile(api, sys.argv[1:], os.environ.get('CALLER_WORKFLOW')) logging.info('Reconciled release PRs: %s', ', '.join(f'#{n}' for n in done) or 'none') diff --git a/release/release-range.py b/release/release-range.py new file mode 100644 index 0000000..9f26a18 --- /dev/null +++ b/release/release-range.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +"""Print the `BEFORE AFTER` pair validate-release.py checks, for a main push or a recovery dispatch. + +A dispatch replays the push of one release commit for which GitHub created no run. +""" + +import logging +from pathlib import Path +import re +import runpy +import sys + +VALIDATION = runpy.run_path(str(Path(__file__).resolve().with_name('validate-release.py'))) +git = VALIDATION['git'] +MAIN = 'refs/remotes/origin/main' + + +def dispatch_range(commit): + if not re.fullmatch(r'[0-9a-f]{40}', commit) or commit == '0' * 40: + raise ValueError('release-commit must be a full commit SHA') + if git('cat-file', '-t', commit).strip() != 'commit': + raise ValueError('release-commit must be a full commit SHA') + fields = git('rev-list', '--parents', '-n', '1', commit).split() + if len(fields) != 2: + raise ValueError('release commit must have exactly one parent') + # With squash merges every first-parent commit of main was the head of one push. + if commit not in git('rev-list', '--first-parent', MAIN).split(): + raise ValueError('release commit is not on the first-parent history of main') + return fields[1], commit + + +def main(arguments): + match arguments: + case ['push', before, after]: + sys.stdout.write(f'{before} {after}\n') + case ['dispatch', commit]: + sys.stdout.write(' '.join(dispatch_range(commit)) + '\n') + case _: + raise ValueError('usage: release-range.py push BEFORE AFTER | dispatch COMMIT') + + +if __name__ == '__main__': + logging.basicConfig(level=logging.INFO, format='%(message)s') + try: + main(sys.argv[1:]) + except (ValueError, OSError) as error: + logging.error('release range failed: %s', error) + sys.exit(1) diff --git a/release/test_reconcile_release_prs.py b/release/test_reconcile_release_prs.py index c476cc1..5bccfac 100644 --- a/release/test_reconcile_release_prs.py +++ b/release/test_reconcile_release_prs.py @@ -117,6 +117,17 @@ def test_missing_or_foreign_tag_fails_without_label_change(self): self.run_reconcile(api) self.assertEqual(api.writes, []) + def test_missing_tag_prints_the_recovery_dispatch(self): + cases = (('owner/repo/.github/workflows/release.yml@refs/heads/main', 'release.yml'), + (None, '')) + for caller_workflow, name in cases: + with self.subTest(caller_workflow=caller_workflow): + patches, _ = validation(BOTH) + with patch.dict(module.VALIDATION, patches), self.assertRaises(ValueError) as raised: + module.reconcile(FakeAPI(tags={}), POLICIES, caller_workflow) + self.assertTrue(str(raised.exception).endswith( + f'recover with: gh workflow run {name} --ref main -f release-commit={COMMIT}')) + def test_tag_alone_keeps_package_release_pending_until_publication(self): api = FakeAPI(releases={}) with self.assertRaisesRegex(ValueError, 'GitHub Release v1.0.0.*missing'): diff --git a/release/test_release_range.py b/release/test_release_range.py new file mode 100644 index 0000000..89d81b0 --- /dev/null +++ b/release/test_release_range.py @@ -0,0 +1,91 @@ +import importlib.util +import os +from pathlib import Path +import subprocess +import sys +import tempfile +import unittest + +SCRIPT = Path(__file__).with_name('release-range.py') +spec = importlib.util.spec_from_file_location('release_range', SCRIPT) +module = importlib.util.module_from_spec(spec) +spec.loader.exec_module(module) + + +class ReleaseRangeTest(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.root = Path(self.tmp.name) + previous = os.getcwd() + os.chdir(self.root) + self.addCleanup(self.tmp.cleanup) + self.addCleanup(os.chdir, previous) + self.git('init', '-q', '-b', 'main') + self.git('config', 'user.name', 'Test') + self.git('config', 'user.email', 'test@example.com') + self.first = self.commit('first') + self.second = self.commit('second') + self.publish(self.second) + + def git(self, *args): + return subprocess.check_output(['git', *args], text=True).strip() + + def commit(self, message): + self.git('commit', '-qm', message, '--allow-empty') + return self.git('rev-parse', 'HEAD') + + def publish(self, sha): + self.git('update-ref', 'refs/remotes/origin/main', sha) + + def cli(self, *args): + return subprocess.run([sys.executable, str(SCRIPT), *args], capture_output=True, text=True, check=False) + + def test_dispatch_replays_the_parent_to_commit_push(self): + self.publish(self.commit('later')) + self.assertEqual(module.dispatch_range(self.second), (self.first, self.second)) + + def test_dispatch_requires_a_full_lowercase_non_zero_sha(self): + for value in (self.second[:12], self.second.upper(), '0' * 40, '', 'main'): + with self.subTest(value=value), self.assertRaisesRegex(ValueError, 'full commit SHA'): + module.dispatch_range(value) + + def test_dispatch_rejects_a_non_commit_object(self): + with self.assertRaisesRegex(ValueError, 'full commit SHA'): + module.dispatch_range(self.git('rev-parse', f'{self.second}^{{tree}}')) + + def test_dispatch_rejects_a_root_commit(self): + with self.assertRaisesRegex(ValueError, 'exactly one parent'): + module.dispatch_range(self.first) + + def test_dispatch_rejects_merge_and_side_branch_commits(self): + self.git('checkout', '-qb', 'side') + side = self.commit('side') + self.git('checkout', '-q', 'main') + self.git('merge', '-q', '--no-ff', '-m', 'merge', 'side') + merge = self.git('rev-parse', 'HEAD') + self.publish(merge) + with self.assertRaisesRegex(ValueError, 'exactly one parent'): + module.dispatch_range(merge) + with self.assertRaisesRegex(ValueError, 'first-parent'): + module.dispatch_range(side) + + def test_dispatch_rejects_a_commit_absent_from_origin_main(self): + with self.assertRaisesRegex(ValueError, 'first-parent'): + module.dispatch_range(self.commit('unpushed')) + + def test_push_range_passes_through(self): + result = self.cli('push', '0' * 40, self.second) + self.assertEqual((result.returncode, result.stdout), (0, f'{"0" * 40} {self.second}\n')) + + def test_cli_dispatch_and_failures(self): + result = self.cli('dispatch', self.second) + self.assertEqual((result.returncode, result.stdout), (0, f'{self.first} {self.second}\n')) + for args in (('dispatch', 'a' * 40), ('dispatch', 'short'), ('schedule',)): + with self.subTest(args=args): + result = self.cli(*args) + self.assertEqual((result.returncode, result.stdout), (1, '')) + self.assertIn('release range failed: ', result.stderr) + + +if __name__ == '__main__': + unittest.main() From bc3741c919d6c278150c7f1ad156120febd6b5e4 Mon Sep 17 00:00:00 2001 From: mignot Date: Wed, 2 Dec 2026 19:53:49 +0100 Subject: [PATCH 2/4] fix(release-tag): keep the publisher bound to the release commit and document recovery limits Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/publish-python.yml | 5 ++--- .github/workflows/python-check.yml | 5 +++++ README.md | 14 ++++++++++---- examples/release-please-python.yml | 3 +++ release/test_python_artifact.py | 11 +++++++++++ 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-python.yml b/.github/workflows/publish-python.yml index 9af3d95..3f81815 100644 --- a/.github/workflows/publish-python.yml +++ b/.github/workflows/publish-python.yml @@ -87,7 +87,8 @@ jobs: esac - uses: actions/checkout@v5 with: - ref: ${{ github.sha }} + # The release commit, not the tag: python-artifact.py then rejects a tag pointing anywhere else. + ref: ${{ github.event.inputs.release-commit || github.sha }} fetch-depth: 0 persist-credentials: false path: caller @@ -111,8 +112,6 @@ jobs: sleep 5 done [ "$fetched" = true ] || { echo "Tag $RELEASE_TAG could not be fetched" >&2; exit 1; } - # A dispatched recovery runs on main's HEAD; build the tagged commit. - git checkout --quiet --detach "refs/tags/$RELEASE_TAG^{commit}" - uses: actions/checkout@v5 with: repository: BehindTheMusicTree/github-workflows diff --git a/.github/workflows/python-check.yml b/.github/workflows/python-check.yml index 54afd07..d79f5d8 100644 --- a/.github/workflows/python-check.yml +++ b/.github/workflows/python-check.yml @@ -6,6 +6,10 @@ name: Python check on: workflow_call: inputs: + ref: + description: Commit to check, empty for the triggering commit; a release gate passes inputs.release-commit || github.sha + default: '' + type: string target: description: check.sh target, lint or test; any other value fails before the job starts work required: true @@ -64,6 +68,7 @@ jobs: fi - uses: actions/checkout@v5 with: + ref: ${{ inputs.ref }} persist-credentials: false - name: Write environment if: ${{ inputs.env != '' }} diff --git a/README.md b/README.md index d511b2f..d543437 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,8 @@ default), checks their metadata, and uploads them with a SHA-256 manifest. It ru the release run of a **push to `main`** (or of the dispatch that [recovers one](#recovering-a-release-push-that-produced-no-run)), after a `release-tag.yml` job of the same run has created the package's tag: pass that job's `tag` output as -`release-tag`. The workflow checks out and builds the tagged commit, which on a push is the -run's own commit. That commit must descend from `origin/main`, the +`release-tag`. The workflow checks out the release commit (the dispatched `release-commit`, +otherwise the run's own commit), and fails unless the tag points at it. That commit must descend from `origin/main`, the selected release policy (default `.github/release-policy.json`) must be valid with matching canonical version/mirrors and populated release notes. Put the exact `package-name` in the policy's `outputs.packages` array. Only stable `X.Y.Z` versions are supported. @@ -143,7 +143,9 @@ conditions explicitly: succeeds by installing an older graph that the root range allows while the Simple index page is stale, and the root tag would be created on an unpublished dependency. A root-only release publishes nothing in the run (`needs.tag-graph.outputs.tag == ''`), so the step - makes a single attempt: the pinned version is already public and a failure is real. + makes a single attempt: the pinned version is already public and a failure is real. If the + graph release push produced no run, a later push fails here: [dispatch the + recovery](#recovering-a-release-push-that-produced-no-run) for the graph release commit. Use only the per-commit group `-${{ inputs.release-commit || github.sha }}` with `cancel-in-progress: false`, as the example does: a ref-level group replaces a pending run and drops its release bump. A registry visibility delay no longer needs a rerun (see the waits above); @@ -666,7 +668,7 @@ A repository releasing several independent components (for example `v*` and `gra Use the [caller example](examples/release-tag.yml), replacing its placeholder with a full **merged and reviewed commit SHA**. Every `uses:` of `release-tag.yml`, `release-github.yml`, `release-please.yml` or `publish-python.yml` from this repository in the adopter's `.github/workflows/` must carry that same SHA: the validation job fails, before any tag exists, when one differs. Align pins in a single PR; a bump of the pin is a release-workflow change like any other. Configure `RELEASE_APP_ID` and the explicitly named `RELEASE_APP_PRIVATE_KEY` secret. Install the App on the adopting repository with Contents write permission; select only adopting repositories for organization secrets. Do not pass registry credentials or `secrets: inherit`. -Before enabling a caller, configure separate tag rulesets: creation permits the release App; update/deletion protection has no App bypass. The App must have no bypass of `main` protection. PR checks must cover the version and publisher changes before merge. If a repository also requires checks after merge, add those jobs in the caller's push workflow and make the reusable-workflow job depend on their successful completion with `needs`. Those checks must operate on `inputs.release-commit || github.sha` (they must check out that ref, so that a [recovery dispatch](#recovering-a-release-push-that-produced-no-run) checks the release commit), including reruns after a later push; a check of the latest branch tip is insufficient. +Before enabling a caller, configure separate tag rulesets: creation permits the release App; update/deletion protection has no App bypass. The App must have no bypass of `main` protection. PR checks must cover the version and publisher changes before merge. If a repository also requires checks after merge, add those jobs in the caller's push workflow and make the reusable-workflow job depend on their successful completion with `needs`. Those checks must operate on `inputs.release-commit || github.sha` (they must check out that ref, so that a [recovery dispatch](#recovering-a-release-push-that-produced-no-run) checks the release commit; `python-check.yml` takes it as its `ref` input), including reruns after a later push; a check of the latest branch tip is insufficient. Activation and changes to the contract must land in a separate push from a version bump. Activation validates the current version, mirrors and changelog but never tags it, including an existing version with no tag. A subsequent push with no bump also produces no tag. For an established contract, a bump must increase the version and leave the policy unchanged; all mirrors and its changelog section must match. The version comparison uses the push's before/after commits, never the current branch tip. Force pushes and newly created branch events fail closed. @@ -694,6 +696,10 @@ gh workflow run .yml --ref main -f release-commit= The run replays the lost push: it validates the range `parent..commit` with the same release policies, using the workflow pins of `main`'s head, then tags and publishes that commit. It is idempotent: an existing tag or GitHub Release on the same commit counts as success, and a commit without a version bump releases nothing. The commit must have exactly one parent and be on the first-parent history of `main`, as every squash merge is. The caller needs the `workflow_dispatch` trigger and the concurrency group shown in the [examples](examples/release-please.yml). +GitHub can refuse the tag or the GitHub Release (HTTP 403, `Resource not accessible by integration`) when the release commit's `.github/workflows/` matches no branch tip, because neither the release App nor `GITHUB_TOKEN` holds the `workflows` permission ([reported behaviour](https://github.com/mihazs/lazysh/pull/1196), not in GitHub's documentation). This happens when a workflow changed on `main` after the release commit. Push a temporary branch at that commit with your own credentials (`git push origin :refs/heads/recover-release`), dispatch again, then delete the branch. + +PyPI publish attestations of a recovered package name the dispatched run's commit (`main`'s head) as their source digest, not the tagged commit: the digest comes from the run's OIDC `sha` claim ([Fulcio](https://github.com/sigstore/fulcio/blob/main/docs/oid-info.md)). The files themselves are built from the tagged commit. + **Deprecated:** `release-github.yml`, and the pattern of a tag-push workflow that calls it, remain only for callers not yet migrated (currently `the-music-tree-pipelines`, `hear-the-music-tree-api` and `python-project-standards`); its pin must equal the tagging pin. New adopters use the [release-please callers](examples/release-please.yml). Removal is planned for a future major version, once those callers have migrated. Repositories whose policy declares `github_release: true` and an empty `packages` list can diff --git a/examples/release-please-python.yml b/examples/release-please-python.yml index 02bf0c2..2483f4b 100644 --- a/examples/release-please-python.yml +++ b/examples/release-please-python.yml @@ -118,6 +118,9 @@ jobs: python3 -m pip install --no-cache-dir . "example-graph==$GRAPH_VERSION" && exit 0 if [ "$SECONDS" -ge "$deadline" ]; then echo "example-graph $GRAPH_VERSION is not installable (${SECONDS}s elapsed)" >&2 + if [ -z "$GRAPH_TAG" ]; then + echo "If the push that released it produced no run, dispatch this workflow with release-commit=" >&2 + fi exit 1 fi echo "example-graph $GRAPH_VERSION not yet installable (attempt $attempt, ${SECONDS}s elapsed)" >&2 diff --git a/release/test_python_artifact.py b/release/test_python_artifact.py index f9d6147..ac78acf 100644 --- a/release/test_python_artifact.py +++ b/release/test_python_artifact.py @@ -383,6 +383,17 @@ def commit(self): def source(self, name='alpha-pkg', tag='alpha-v2.3.4', directory='packages/alpha', policy='.github/alpha.json'): return module.source_version(name, tag, package_directory_path=directory, release_policy_path=policy) + def test_tag_of_another_commit_than_the_checkout_fails(self): + self.write('sample.py', 'VALUE = 2\n') + self.commit() + with self.assertRaisesRegex(ValueError, 'tag commit'): + module.source_version('root-pkg', 'v1.0.0') + + def test_publisher_checks_out_the_release_commit_not_the_tag(self): + workflow = (Path(__file__).parent.parent / '.github/workflows/publish-python.yml').read_text() + self.assertIn('ref: ${{ github.event.inputs.release-commit || github.sha }}', workflow) + self.assertNotIn('git checkout', workflow) + def test_root_defaults_are_compatible(self): self.assertEqual(module.source_version('root-pkg', 'v1.0.0'), '1.0.0') From 977251757a5c12dffe1734be3e0f7c5d64d6d2ad Mon Sep 17 00:00:00 2001 From: mignot Date: Wed, 2 Dec 2026 19:55:27 +0100 Subject: [PATCH 3/4] docs(release-tag): complete the lost graph push recovery steps Co-Authored-By: Claude Sonnet 5.5 --- README.md | 6 ++++-- examples/release-please-python.yml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d543437..e3a43e7 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,9 @@ conditions explicitly: release publishes nothing in the run (`needs.tag-graph.outputs.tag == ''`), so the step makes a single attempt: the pinned version is already public and a failure is real. If the graph release push produced no run, a later push fails here: [dispatch the - recovery](#recovering-a-release-push-that-produced-no-run) for the graph release commit. + recovery](#recovering-a-release-push-that-produced-no-run) for the graph release commit, + then **Re-run failed jobs** on the later push's run, which tags the root and reconciles its + release PR (until then, the dispatched run's `release-please` job can fail on that PR). Use only the per-commit group `-${{ inputs.release-commit || github.sha }}` with `cancel-in-progress: false`, as the example does: a ref-level group replaces a pending run and drops its release bump. A registry visibility delay no longer needs a rerun (see the waits above); @@ -696,7 +698,7 @@ gh workflow run .yml --ref main -f release-commit= The run replays the lost push: it validates the range `parent..commit` with the same release policies, using the workflow pins of `main`'s head, then tags and publishes that commit. It is idempotent: an existing tag or GitHub Release on the same commit counts as success, and a commit without a version bump releases nothing. The commit must have exactly one parent and be on the first-parent history of `main`, as every squash merge is. The caller needs the `workflow_dispatch` trigger and the concurrency group shown in the [examples](examples/release-please.yml). -GitHub can refuse the tag or the GitHub Release (HTTP 403, `Resource not accessible by integration`) when the release commit's `.github/workflows/` matches no branch tip, because neither the release App nor `GITHUB_TOKEN` holds the `workflows` permission ([reported behaviour](https://github.com/mihazs/lazysh/pull/1196), not in GitHub's documentation). This happens when a workflow changed on `main` after the release commit. Push a temporary branch at that commit with your own credentials (`git push origin :refs/heads/recover-release`), dispatch again, then delete the branch. +GitHub can refuse the tag or the GitHub Release (HTTP 403, `Resource not accessible by integration`) when the release commit's `.github/workflows/` matches no branch tip, because `GITHUB_TOKEN` never holds the `workflows` permission and the release App is not granted it ([reported behaviour](https://github.com/mihazs/lazysh/pull/1196) for `GITHUB_TOKEN`, expected for the App too; not in GitHub's documentation). This happens when a workflow changed on `main` after the release commit. Push a temporary branch at that commit with your own credentials (`git push origin :refs/heads/recover-release`), dispatch again, then delete the branch. PyPI publish attestations of a recovered package name the dispatched run's commit (`main`'s head) as their source digest, not the tagged commit: the digest comes from the run's OIDC `sha` claim ([Fulcio](https://github.com/sigstore/fulcio/blob/main/docs/oid-info.md)). The files themselves are built from the tagged commit. diff --git a/examples/release-please-python.yml b/examples/release-please-python.yml index 2483f4b..93d3837 100644 --- a/examples/release-please-python.yml +++ b/examples/release-please-python.yml @@ -119,7 +119,7 @@ jobs: if [ "$SECONDS" -ge "$deadline" ]; then echo "example-graph $GRAPH_VERSION is not installable (${SECONDS}s elapsed)" >&2 if [ -z "$GRAPH_TAG" ]; then - echo "If the push that released it produced no run, dispatch this workflow with release-commit=" >&2 + echo "If the push that released it produced no run, dispatch this workflow with release-commit=, then re-run this run's failed jobs" >&2 fi exit 1 fi From 4ab212a1591e5cda3c41df34fdc35c8e85b33868 Mon Sep 17 00:00:00 2001 From: mignot Date: Wed, 2 Dec 2026 19:56:20 +0100 Subject: [PATCH 4/4] docs(release-tag): wait for the recovery run before re-running the later one Co-Authored-By: Claude Sonnet 5.5 --- README.md | 5 +++-- examples/release-please-python.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e3a43e7..73a7f0d 100644 --- a/README.md +++ b/README.md @@ -146,8 +146,9 @@ conditions explicitly: makes a single attempt: the pinned version is already public and a failure is real. If the graph release push produced no run, a later push fails here: [dispatch the recovery](#recovering-a-release-push-that-produced-no-run) for the graph release commit, - then **Re-run failed jobs** on the later push's run, which tags the root and reconciles its - release PR (until then, the dispatched run's `release-please` job can fail on that PR). + and once the dispatched run's `verify-public-dependency` has succeeded, **Re-run failed jobs** + on the later push's run, which tags the root and reconciles its release PR (until then, the + dispatched run's `release-please` job can fail on that PR). Use only the per-commit group `-${{ inputs.release-commit || github.sha }}` with `cancel-in-progress: false`, as the example does: a ref-level group replaces a pending run and drops its release bump. A registry visibility delay no longer needs a rerun (see the waits above); diff --git a/examples/release-please-python.yml b/examples/release-please-python.yml index 93d3837..d983d2c 100644 --- a/examples/release-please-python.yml +++ b/examples/release-please-python.yml @@ -119,7 +119,7 @@ jobs: if [ "$SECONDS" -ge "$deadline" ]; then echo "example-graph $GRAPH_VERSION is not installable (${SECONDS}s elapsed)" >&2 if [ -z "$GRAPH_TAG" ]; then - echo "If the push that released it produced no run, dispatch this workflow with release-commit=, then re-run this run's failed jobs" >&2 + echo "If the push that released it produced no run, dispatch this workflow with release-commit=; once its verify-public-dependency succeeds, re-run this run's failed jobs" >&2 fi exit 1 fi