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
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: Optional release version overriding the checked-in version.
type: string
required: false
dry-run:
description: Check release prerequisites without releasing.
type: boolean
default: false

permissions:
contents: write
id-token: write

jobs:
release:
uses: dblock/ruby-gem-release/.github/workflows/release.yml@v0.9.0
with:
ruby-version: '4.0'
gemfile: gemfiles/release.gemfile
version: ${{ inputs.version }}
dry-run: ${{ inputs.dry-run }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ test/version_tmp
tmp
examples/william.rb
Gemfile.lock
gemfiles/*.lock
vendor/bundle
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* [#338](https://github.com/codegram/hyperclient/pull/338): Documented link properties, including HAL `profile` via `Link#_profile` - [@dblock](https://github.com/dblock).
* [#339](https://github.com/codegram/hyperclient/pull/339): Sped up CI by running JRuby with `--dev`, separating JSON 2 and JSON 3 bundler caches, skipping duplicate branch builds, and updating `actions/checkout` to v7 - [@dblock](https://github.com/dblock).
* [#340](https://github.com/codegram/hyperclient/pull/340): Added `Link#_allow`, `Link#_allow?`, `Resource#_allow` and `Resource#_allow?` to read the `Allow` header, and an opt-in `enforce_allowed_methods` setting that raises `Hyperclient::MethodNotAllowedError` instead of sending a method the link's most recent response disallowed - [@dblock](https://github.com/dblock).
* [#341](https://github.com/codegram/hyperclient/pull/341): Added a Release workflow using [ruby-gem-release](https://github.com/dblock/ruby-gem-release) and RubyGems Trusted Publishing, and disabled the local `rake release` task - [@dblock](https://github.com/dblock).
* Your contribution here.

### 2.1.0 (2026/10/14)
Expand Down
71 changes: 27 additions & 44 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,57 @@

Release bug fixes frequently, features less frequently, and breaking API changes rarely.

## Prepare the Release
Releases run through the [Release workflow](.github/workflows/release.yml), which uses [ruby-gem-release](https://github.com/dblock/ruby-gem-release/tree/v0.9.0) and RubyGems Trusted Publishing. Merging does not publish anything, and the local Bundler `rake release` task is disabled.

Start with a clean, up-to-date `master` branch. Check that CI has succeeded for all supported platforms.
## One-Time Setup

Set the release version in [lib/hyperclient/version.rb](lib/hyperclient/version.rb). Use a patch version for backward-compatible fixes, a minor version for backward-compatible features, and a major version for breaking changes.
Create a GitHub environment named `release` in this repository, for example with `gh api --method PUT repos/codegram/hyperclient/environments/release`. To require a maintainer's approval before publication, add required reviewers and restrict deployment to `master`.

Replace the next-version heading in [CHANGELOG.md](CHANGELOG.md) with the release version and date, for example `### 2.1.0 (2026/10/14)`. Remove the "Your contribution here." placeholder from that release.
On RubyGems, open the [hyperclient trusted publishers](https://rubygems.org/gems/hyperclient/trusted_publishers) page and add a GitHub Actions publisher with repository owner `codegram`, repository name `hyperclient`, workflow filename `release.yml`, and environment `release`. Set the separate workflow repository owner to `dblock` and name to `ruby-gem-release`, because publication runs in that reusable workflow. No RubyGems API key is stored.

Run the full suite, then commit and push the release preparation:
The workflow needs to push the release commit, the `vVERSION` tag, and the next development commit to `master`. Branch and tag rules must allow that; every release checks them before publishing.

```sh
bundle install
bundle exec rake
git add CHANGELOG.md lib/hyperclient/version.rb
git commit -m "Preparing for release, 2.1.0."
git push origin master
```
## Prepare the Release

Releases publish the version in [lib/hyperclient/version.rb](lib/hyperclient/version.rb) with the notes in its `### VERSION (Next)` section of [CHANGELOG.md](CHANGELOG.md). Use a patch version for backward-compatible fixes, a minor version for backward-compatible features, and a major version for breaking changes. To change it, update both files in a pull request, or pass a different version when starting the release.

Wait for CI on the release preparation commit to succeed before publishing.
Check that CI has succeeded on `master`, and don't merge anything while a release is running.

## Publish to RubyGems and GitHub
## Release

Publish the gem using Bundler's release task. This builds the gem, creates and pushes the version tag, and publishes to RubyGems. Complete RubyGems MFA when prompted.
Check the setup without releasing anything:

```sh
bundle exec rake release
gh workflow run release.yml --repo codegram/hyperclient --ref master -f dry-run=true
```

Creating a Git tag does **not** create a GitHub release. After confirming that the gem was published successfully, create a GitHub release for the same tag. Put the matching changelog section's entries in a temporary file and use them as the release notes:
Then release the checked-in version:

```sh
version=2.1.0
notes="$(mktemp)"
awk -v version="$version" '
/^### / {
if (found) exit
if ($2 == version) found = 1
next
}
found { print }
' CHANGELOG.md > "$notes"
gh release create "v$version" --repo codegram/hyperclient --verify-tag --title "$version" --notes-file "$notes" --latest
rm "$notes"
gh workflow run release.yml --repo codegram/hyperclient --ref master
```

Verify both publications before considering the release complete:
To release a different version, pass `-f version=2.3.0`.

The workflow runs `bundle exec rake` on Ruby 4.0 with [gemfiles/release.gemfile](gemfiles/release.gemfile), dates the changelog section and removes its "Your contribution here." placeholder, publishes the gem to RubyGems, pushes the release commit and tag, and creates a GitHub Release with the changelog notes. It then increments the patch version and pushes a new `### VERSION (Next)` section to `master`.

## Verify and Recover

Check the RubyGems version, the matching tag and GitHub Release, and the next development version on `master`:

```sh
version=2.2.0
curl --fail --silent --show-error "https://rubygems.org/api/v2/rubygems/hyperclient/versions/$version.json"
gh release view "v$version" --repo codegram/hyperclient
```

If publishing is interrupted, inspect the existing tag, RubyGems version, and GitHub release first. Resume only the missing step; do not move or recreate a published tag.

## Prepare the Next Version
Don't rerun a failed release blindly: RubyGems may have accepted the gem. Inspect the existing tag, RubyGems version, and GitHub Release first, and never republish a version or move its tag. Follow the [ruby-gem-release recovery instructions](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/actions/release.md#recovery-artifacts) to complete only the missing steps.

Increment the development patch version in [lib/hyperclient/version.rb](lib/hyperclient/version.rb), for example from `2.1.0` to `2.1.1`. Add the matching unreleased section at the top of [CHANGELOG.md](CHANGELOG.md):

```markdown
### 2.1.1 (Next)

* Your contribution here.
```
## Run the Release Tasks Locally

Commit and push:
The release tasks need Ruby 3.3+ and the release bundle:

```sh
git add CHANGELOG.md lib/hyperclient/version.rb
git commit -m "Preparing for next release, 2.1.1."
git push origin master
BUNDLE_GEMFILE=gemfiles/release.gemfile bundle install
BUNDLE_GEMFILE=gemfiles/release.gemfile bundle exec rake -T release
```
18 changes: 18 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ Bundler.setup :default, :test, :development

Bundler::GemHelper.install_tasks

# Releases run through the Release workflow, see RELEASING.md.
%w[release release:rubygem_push release:source_control_push].each do |name|
Rake::Task[name].clear
desc 'Disabled, releases run through the Release workflow (see RELEASING.md)'
task(name) { abort "#{name} is disabled; releases run through GitHub Actions, see RELEASING.md" }
end

# The release tasks are only installed with BUNDLE_GEMFILE=gemfiles/release.gemfile.
if Gem.loaded_specs.key?('ruby-gem-release')
require 'ruby-gem-release/workflow/ruby_gem'
require 'ruby-gem-release/changelog'

RubyGemRelease::Workflow::RubyGem.new(
version: RubyGemRelease::Version::RubyConstant.new(path: 'lib/hyperclient/version.rb', constant: 'VERSION'),
changelog: RubyGemRelease::Changelog::Intridea.new(placeholder: '* Your contribution here.')
).install_tasks
end

require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
Expand Down
6 changes: 6 additions & 0 deletions gemfiles/release.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Bundle used by the Release workflow, see RELEASING.md.
# ruby-gem-release requires Ruby 3.3+, so it is kept out of the main Gemfile.
eval_gemfile '../Gemfile'

gem 'commonmarker', '~> 2.10', require: false
gem 'ruby-gem-release', '0.9.0', require: false
Loading