diff --git a/CHANGELOG.md b/CHANGELOG.md index 9787ed8..6b5b470 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [#90](https://github.com/dblock/ruby-gem-release/pull/90): Publish the released changelog section as GitHub Release notes in the standard workflow instead of generated notes, read before any publication - [@dblock](https://github.com/dblock). - [#91](https://github.com/dblock/ruby-gem-release/pull/91): Accept an Intridea Next section with release notes but no contribution placeholder, rejecting a placeholder marked differently from the configured one - [@dblock](https://github.com/dblock). +- [#92](https://github.com/dblock/ruby-gem-release/pull/92): Document manual recovery from the preserved bundle when the default branch advances during publication - [@dblock](https://github.com/dblock). - Your contribution here. ## 0.9.0 (2026/11/20) diff --git a/README.md b/README.md index 83417f5..adb5edf 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Collaborators with write access can dispatch releases after this setup, without ### 4. Make a Release -Your branch rules must permit release commits and tags to be pushed; see [branch permissions](RELEASING.md#one-time-setup). Each release checks this before publishing. Dispatching starts a publishing run; when required reviewers are configured, the release job waits for approval from a designated maintainer. Run your project's tests and build checks, review the changes, and dispatch from your default branch: +Your branch rules must permit release commits and tags to be pushed; see [branch permissions](RELEASING.md#one-time-setup). Each release checks this before publishing. Dispatching starts a publishing run; when required reviewers are configured, the release job waits for approval from a designated maintainer. Run your project's tests and build checks, review the changes, and dispatch from your default branch: Do not merge into the default branch while a release runs; see [recovery](docs/actions/release.md#default-branch-advanced-during-publication). **First release:** Pass the numeric RubyGems account ID shown on the Pending Trusted Publishers page as `rubygems-owner`. This declares the account that will own the gem on its first publication. Replace `YOUR_ACCOUNT_ID` below with that ID: diff --git a/RELEASING.md b/RELEASING.md index f545509..441cb93 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -74,7 +74,7 @@ Builds overwrite local artifacts reproducibly. Capture exports the committer tim Git reuses matching release and development trees without moving tags or rewinding remote descendants. Development bumps calculate from the supplied release version, so repetition does not increment twice. GitHub replaces differing release metadata, notes read from the changelog, and assets; unspecified platform-generated notes are retained. -Actions preserves `release.gem`, its name/version/digest manifest `release.json`, and `release.bundle` before publication for 30 days. These are for manual inspection, not automatic restoration. Conflicting checksums or tags and unrelated branch advancement require investigation; do not overwrite immutable releases. +Actions preserves `release.gem`, its name/version/digest manifest `release.json`, and `release.bundle` before publication for 30 days. These are for manual inspection, not automatic restoration. Conflicting checksums or tags and unrelated branch advancement require investigation; do not overwrite immutable releases. If the default branch advanced during publication, follow [the manual recovery](docs/actions/release.md#default-branch-advanced-during-publication). All custom commands and callbacks must be idempotent too. Notifications need receiver-side readback or a stable key such as `"release/example/1.2.3/success"`, never a run ID. They may execute again; without receiver support, exactly-once delivery and automatic detection of an unfinished notification are impossible. Release reconciliation proves package, Git, hosting, and development completion, not arbitrary external callback completion. diff --git a/docs/actions/action.md b/docs/actions/action.md index 6921c32..fbe9eb4 100644 --- a/docs/actions/action.md +++ b/docs/actions/action.md @@ -76,4 +76,4 @@ For first publication, register a pending trusted publisher and supply its numer With the sample, dispatch a first release using `gh workflow run release.yml -f rubygems-owner=YOUR_ACCOUNT_ID`, replacing `YOUR_ACCOUNT_ID` with your numeric account ID. For subsequent releases, omit `rubygems-owner`. Validate locally before authorizing publication. -Artifacts must be preserved before publication. Reruns use the supplied checkout and inputs, not restored context or automatically discovered unfinished releases. See [Verify and Recover](../../RELEASING.md#verify-and-recover). +Do not merge into the default branch while a release runs; see [recovery](release.md#default-branch-advanced-during-publication). Artifacts must be preserved before publication. Reruns use the supplied checkout and inputs, not restored context or automatically discovered unfinished releases. See [Verify and Recover](../../RELEASING.md#verify-and-recover). diff --git a/docs/actions/release.md b/docs/actions/release.md index f76f768..248dea4 100644 --- a/docs/actions/release.md +++ b/docs/actions/release.md @@ -164,6 +164,46 @@ GitHub also supplies standard variables such as `GITHUB_REPOSITORY` and `RUNNER_ ## Recovery Artifacts -The workflow requires `release.gem`, its name/version/digest manifest `release.json`, and `release.bundle` to be uploaded before publication, retained for 30 days under `release-gem-VERSION-RUN_ID-RUN_ATTEMPT`. These support manual inspection, not automatic restoration. See [RELEASING.md](../../RELEASING.md#verify-and-recover). +The workflow requires `release.gem`, its name/version/digest manifest `release.json`, and `release.bundle` to be uploaded before publication, retained for 30 days under `release-gem-VERSION-RUN_ID-RUN_ATTEMPT`. These support manual inspection, not automatic restoration. See [RELEASING.md](../../RELEASING.md#verify-and-recover) and [recovery when the default branch advances during publication](#default-branch-advanced-during-publication). For already-reviewed commits, stable branches, existing signed tags, and explicitly supplied package collections, use the [reviewed workflow](../workflow/reviewed_ruby_gem.md). It retains publication guards but makes no release preparation commits, new tags, Git pushes, or development bumps. `prepare-artifacts` and `artifacts` support explicit retained inputs without artifact discovery; both interfaces expose the same inputs. + +### Default Branch Advanced During Publication + +Do not merge into the default branch while a release runs. The tag step fails before publication if the branch has moved since capture, but a merge after that check and before the release push leaves the gem published on RubyGems while the push fails with `Default branch advanced; start a new release`. The release tag, the release commit on the default branch, the GitHub Release, and the next development iteration are then missing. Rerunning does not recover: each run creates a new release commit, and tagging requires the branch to still be at the source commit. Recover manually from the preserved artifacts instead, replacing `1.2.3`, `example`, `RUN_ID`, and `ATTEMPT`: + +**Step 1.** Download the failed run's artifacts and confirm RubyGems published the preserved archive: + +```sh +gh run download RUN_ID -n release-gem-1.2.3-RUN_ID-ATTEMPT -D release-artifacts +jq -r .sha256 release-artifacts/release.json +curl -s https://rubygems.org/api/v1/versions/example.json | jq -r '.[] | select(.number == "1.2.3") | .sha' +``` + +The digests must match. If they differ, or the version is missing, stop and investigate instead. + +**Step 2.** Import the release commit and tag from the bundle, and push the tag. It points at the release commit, whose parent is the dispatched source commit: + +```sh +git fetch release-artifacts/release.bundle 'refs/tags/v1.2.3:refs/tags/v1.2.3' +git push origin refs/tags/v1.2.3 +``` + +**Step 3.** Merge the release commit into the default branch through a pull request, resolving conflicts with the changes merged during the release. Do not rewrite or move the tag. + +```sh +git switch -c release-1.2.3 v1.2.3 +git push origin release-1.2.3 +gh pr create --head release-1.2.3 --title 'Release 1.2.3' +``` + +**Step 4.** Create the GitHub Release with the preserved archive under its gem file name, as normal releases attach it. Write the released changelog section to `NOTES.md`, or replace `--notes-file NOTES.md` with `--generate-notes`: + +```sh +cp release-artifacts/release.gem example-1.2.3.gem +gh release create v1.2.3 --verify-tag --title v1.2.3 --notes-file NOTES.md example-1.2.3.gem +``` + +**Step 5.** Start the next development iteration in a pull request that increments the version and adds the Next changelog section, as the bump would have. + +Do not dispatch a new release of the same version. RubyGems accepts only the identical archive, and a rebuilt release commit would not match the pushed tag.