Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ permissions:
jobs:
release:
if: github.ref == 'refs/heads/main'
uses: dblock/ruby-gem-release/.github/workflows/release.yml@v0.4.0
uses: dblock/ruby-gem-release/.github/workflows/release.yml@v0.6.0
with:
ruby-version: '3.3'
version: ${{ inputs.version }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- [#19](https://github.com/danger/danger-pr-comment/pull/19): Update ruby-gem-release to 0.6.0 and migrate the release context and recovery instructions - [@dblock](https://github.com/dblock).
- [#18](https://github.com/danger/danger-pr-comment/pull/18): Point the README, installer, gemspec, and release tooling at the `danger` organization after the repository transfer - [@numbata](https://github.com/numbata).
- [#16](https://github.com/danger/danger-pr-comment/pull/16): Remove the `RELEASERS` allowlist and actor-matching release gate in favor of GitHub environment approval configuration - [@dblock](https://github.com/dblock).
- [#15](https://github.com/danger/danger-pr-comment/pull/15): Migrate release automation to [ruby-gem-release](https://github.com/dblock/ruby-gem-release) 0.4.0, preserving release access restrictions and workflow reference updates while allowing unpublished maintenance versions below the latest release - [@dblock](https://github.com/dblock).
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ group :development do
gem 'rubocop', '1.82.1'
gem 'rubocop-rake'
gem 'rubocop-rspec'
gem 'ruby-gem-release', '0.4.0'
gem 'ruby-gem-release', '0.6.0'
end

group :test do
Expand Down
14 changes: 7 additions & 7 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Releases use [ruby-gem-release](https://github.com/dblock/ruby-gem-release) and [RubyGems Trusted Publishing](https://guides.rubygems.org/trusted-publishing/#using-reusable-workflows) through GitHub Actions OIDC. No stored RubyGems API key or manual OTP is required.

The development dependency and reusable workflow are pinned to `ruby-gem-release` 0.4.0.
The development dependency and reusable workflow are pinned to `ruby-gem-release` 0.6.0.

## One-time setup

Expand All @@ -25,11 +25,11 @@ gh workflow run release.yml --ref main # release the version in
gh workflow run release.yml --ref main -f version=0.3.0 # release an explicit version
```

The optional `version` input retains its existing behavior: the library's standard preparation writes the requested MAJOR.MINOR.PATCH version before the reusable workflow verifies it against the prepared gemspec. The version must be absent from RubyGems and its release tag must not already exist. Unpublished maintenance versions below the latest release are allowed; there is no version-ordering restriction. A required reviewer must approve the deployment when the `release` environment has approval protection.
The optional `version` input retains its existing behavior: the library's standard preparation writes the requested MAJOR.MINOR.PATCH version before the reusable workflow verifies it against the prepared gemspec. Unpublished maintenance versions below the latest release are allowed; there is no version-ordering restriction. Existing publications are accepted only when the built artifact's checksum matches, and existing tags must match the release commit. A required reviewer must approve the deployment when the `release` environment has approval protection.

The Rakefile installs `ruby-gem-release`'s standard gem workflow without custom task or command overrides. A small Keep a Changelog subclass updates the README, installer, and installer specs to `@vVERSION`, validating every workflow reference before writing release files. Changelog formatting and empty-note validation remain delegated to the library. Do not manually date the changelog or update those references.

The reusable workflow rejects stale dispatches, stages preparation, rejects existing tags and published RubyGems versions, and runs `bundle exec rake` against the prepared release. It commits preparation, builds and verifies the gem, creates a local tag and recovery bundle, publishes to RubyGems, then atomically pushes the prepared commit and tag. It creates a GitHub release with the gem attached, then increments the patch version, opens a fresh `[Unreleased]` section, and pushes the next development iteration. The README and installer continue referencing the published release.
The reusable workflow rejects stale dispatches, validates release preconditions, stages preparation, and runs `bundle exec rake` against the prepared release. It checkpoints the release commit, verified gem, local tag, and recovery bundle, and preserves artifacts before publication. Publication authenticates through the registry destination, verifies or uploads the gem, then atomically pushes the prepared commit and tag. It creates a GitHub release with the gem attached, then increments the patch version, opens a fresh `[Unreleased]` section, and pushes the next development iteration. The README and installer continue referencing the published release.

Publishing before updating `main` and the tag keeps the installer on an existing published workflow tag. Concurrent changes to `main` reject ref updates instead of overwriting them. The automatic `GITHUB_TOKEN` is sufficient, but its pushes do not trigger push-based workflows; validation runs explicitly during release.

Expand All @@ -47,19 +47,19 @@ cat lib/danger-pr-comment/version.rb

## Recover from a failed release

Check which steps succeeded before retrying. RubyGems versions cannot be overwritten, and published tags must not be moved. See the upstream [recovery instructions](https://github.com/dblock/ruby-gem-release/blob/v0.4.0/RELEASING.md#verify-and-recover) for the full procedure.
Check which steps succeeded before retrying. RubyGems versions cannot be overwritten, and published tags must not be moved. See the upstream [recovery instructions](https://github.com/dblock/ruby-gem-release/blob/v0.6.0/RELEASING.md#verify-and-recover) for the full procedure.

The reusable workflow preserves available artifacts even after publication fails, under `release-gem-VERSION-RUN_ID-RUN_ATTEMPT`: `release.gem`, its SHA-256 manifest `release.json`, and `release.bundle` containing the exact prepared commit and tag.
Before publication, the reusable workflow preserves artifacts under `release-gem-VERSION-RUN_ID-RUN_ATTEMPT`: `release.gem`, its SHA-256 manifest `release.json`, and `release.bundle` containing the exact prepared commit and tag. Artifact preservation must succeed before publishing.

* Before publication: fix the failure and dispatch a fresh run. Preparation has not changed `main` or pushed a tag. If an upload failed or timed out, check RubyGems first; the server may have accepted it.
* Gem published, atomic push failed: download the original run's recovery artifact with `gh run download RUN_ID --name release-gem-VERSION-RUN_ID-RUN_ATTEMPT`. Verify the gem and manifest, recover the original tag with `git fetch ./release.bundle refs/tags/vVERSION:refs/tags/vVERSION`, and reconcile any newer commits before pushing the exact release commit and tag. Never force-push `main`, move the release tag, or tag a different commit as the published gem.
* Tag pushed, GitHub release missing: use `gh release create vVERSION --verify-tag --generate-notes`, attaching the recovered original gem.
* Release complete, next iteration failed: pull current `main`, resolve branch permissions or concurrent changes, and increment the version and open `[Unreleased]` only if those changes have not already occurred. Commit and push the missing preparation without publishing again.

Do not rerun the entire workflow after publication to repair a missing tag, release, or version bump. Complete only the missing steps.
The library's tasks reconcile their outputs idempotently when repeated with the same source commit, release version, date, and build inputs. Existing RubyGems versions require an exact SHA-256 match; conflicting tags or checksums fail instead of being overwritten. A fresh dispatch uses its current checkout and inputs, not an automatically restored unfinished release. Recovery artifacts are for manual inspection, not automatic restoration; investigate unrelated branch advancement before rerunning.

If OIDC fails, verify both the caller and reusable-workflow repository fields, workflow filename, environment, and `id-token: write`. Do not add a long-lived API key as a workaround.

## Manual publishing

Trusted publishing authenticates GitHub Actions, not a local shell. Prefer the release workflow. For an exceptional local release, authenticate with your RubyGems account and complete MFA. Start from clean, current `main`, set the release context environment variables documented in [Tasks](https://github.com/dblock/ruby-gem-release/blob/v0.4.0/docs/tasks.md), and use `release:before_release`, validation, `release:publish`, and `release:after_release` in that order. Keep one shared `RUNNER_TEMP` directory across these commands so preparation snapshots and recovery artifacts persist. Publication tasks perform real remote writes; never use them as a preview. The old `scripts/release_version.rb` commands have been replaced by these tasks.
Trusted publishing authenticates GitHub Actions, not a local shell. Prefer the release workflow. For an exceptional local release, authenticate with your RubyGems account and complete MFA. Start from clean, current `main`, set the release context environment variables documented in [Tasks](https://github.com/dblock/ruby-gem-release/blob/v0.6.0/docs/tasks.md), including `GEMSPEC_VERSION`, and use `release:validate`, `release:prepare`, tests, `release:workflow:checkpoint`, `release:publish`, and `release:bump` in that order. Keep one shared `RELEASE_DATA_DIR` directory across these commands so preparation snapshots and recovery artifacts persist. Publication tasks perform real remote writes; never use them as a preview. The old `scripts/release_version.rb` commands have been replaced by these tasks.
2 changes: 1 addition & 1 deletion spec/scripts/release_preparation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_relative '../../scripts/release_preparation'

RSpec.describe ReleaseChangelog do
let(:release) { RubyGemRelease::Release.new(version: '1.2.3', previous_version: '1.2.3', date: Date.new(2026, 11, 8)) }
let(:release) { RubyGemRelease::Release.new(version: '1.2.3', gemspec_version: '1.2.3', date: Date.new(2026, 11, 8)) }
let(:changelog) { described_class.new }
let(:workflow_paths) { %w[README.md scripts/install-workflows.sh spec/scripts/install_workflows_spec.rb] }

Expand Down
Loading