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
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
gemspec:
description: Optional gemspec path; defaults to the only root gemspec.
type: string
gemfile:
description: Gemfile for Bundler, relative to the repository root; its lockfile must be committed or ignored.
type: string
default: Gemfile
rubygems-owner:
description: Optional RubyGems account ID for first publication with a pending trusted publisher.
type: string
Expand Down Expand Up @@ -81,6 +85,7 @@ jobs:
env:
INPUT_VERSION: ${{ inputs.version }}
INPUT_GEMSPEC_PATH: ${{ inputs.gemspec }}
BUNDLE_GEMFILE: ${{ inputs.gemfile }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GIT_USER_NAME: ${{ inputs.git-user-name }}
GIT_USER_EMAIL: ${{ inputs.git-user-email }}
Expand Down Expand Up @@ -114,6 +119,7 @@ jobs:
env:
INPUT_VERSION: ${{ inputs.version }}
INPUT_GEMSPEC_PATH: ${{ inputs.gemspec }}
BUNDLE_GEMFILE: ${{ inputs.gemfile }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GIT_USER_NAME: ${{ inputs.git-user-name }}
GIT_USER_EMAIL: ${{ inputs.git-user-email }}
Expand Down
1 change: 1 addition & 0 deletions .spellcheck.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ GPG
HTTPS
idempotence
Intridea
lockfile
JSON
JRuby
LCOV
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog

## 0.8.1 (Next)
## 0.9.0 (Next)

- [#89](https://github.com/dblock/ruby-gem-release/pull/89): Add a `gemfile` input to the reusable workflow and composite action that selects the Gemfile every release step installs and runs in, so release-only gems can stay out of a project's main bundle - [@dblock](https://github.com/dblock).
- Your contribution here.

## 0.8.0 (2026/11/20)
Expand Down
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ inputs:
gemspec:
description: Optional gemspec path; defaults to the only root gemspec.
default: ''
gemfile:
description: Optional Gemfile for Bundler, relative to the repository root; its lockfile must be committed or ignored. Empty keeps the job's BUNDLE_GEMFILE or Gemfile.
default: ''
rubygems-owner:
description: Optional RubyGems account ID for first publication with a pending trusted publisher.
default: ''
Expand Down Expand Up @@ -62,6 +65,15 @@ runs:
id: checkout
with:
fetch-depth: 0
- name: Select Gemfile
id: select_gemfile
if: ${{ inputs.gemfile != '' }}
shell: bash
env:
RELEASE_GEMFILE: ${{ inputs.gemfile }}
run: |
[[ "$RELEASE_GEMFILE" != *$'\n'* && "$RELEASE_GEMFILE" != *$'\r'* ]] || { echo 'gemfile must be a single line' >&2; exit 1; }
echo "BUNDLE_GEMFILE=$RELEASE_GEMFILE" >> "$GITHUB_ENV"
- uses: ruby/setup-ruby@be3c7df29b3349ec6bcfc6b4792f1cf9f5237d18 # v1.343.0
id: setup_ruby
with:
Expand Down
2 changes: 1 addition & 1 deletion docs/actions/action.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The action checks out the calling repository with full history and sets up Ruby

## Inputs and Environment

Inputs, command defaults, callback semantics, and exported environment variables match the [workflow reference](release.md#inputs). Set them under the action step's `with:` mapping rather than under a reusable-workflow job. All action inputs are strings. Dispatching the sample workflow requests publication; configured environment protection rules must pass before the job runs.
Inputs, command defaults, callback semantics, and exported environment variables match the [workflow reference](release.md#inputs). Set them under the action step's `with:` mapping rather than under a reusable-workflow job. All action inputs are strings. `gemfile` defaults to empty, which keeps a `BUNDLE_GEMFILE` the calling job already sets; a nonempty value is exported for all later steps before Ruby setup. Dispatching the sample workflow requests publication; configured environment protection rules must pass before the job runs.

For [already-reviewed source and package collections](../workflow/reviewed_ruby_gem.md), configure `Workflow::ReviewedRubyGem` in the Rakefile. Optional `prepare-artifacts` prepares explicit input archives after Ruby setup, before loading release tasks for input configuration and capture; `artifacts` adds newline-separated paths to artifact preservation. Both default to empty. Caller-provided commands retain release privileges and must use reviewed inputs.

Expand Down
53 changes: 34 additions & 19 deletions docs/actions/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@ Every action the workflow uses is pinned to a commit SHA. RubyGems Trusted Publi

Set these under the calling job's `with:` mapping. Only `ruby-version` is required.

| Input | Type | Default | Behavior |
| --- | --- | --- | --- |
| `ruby-version` | String | Required | Ruby version used for validation and building. |
| `version` | String | Empty | Selected numeric `MAJOR.MINOR.PATCH` release version, without leading zeros. Overrides the checked-in version in standard preparation. |
| `gemspec` | String | Empty | Specification path, defaulting to the only root gemspec. Missing or ambiguous specifications fail. |
| `rubygems-owner` | String | Empty | Numeric RubyGems account ID required for a new gem's pending trusted publisher to create it. |
| `timezone` | String | `UTC` | Installed timezone identifier for the release calendar date and Git timestamp offsets. |
| `prepare-artifacts` | String | Empty | Trusted command preparing explicitly selected input archives after setup, before capture. |
| `artifacts` | String | Empty | Additional newline-separated artifact paths preserved before publication, alongside default paths. |
| `validate` | String | `bundle exec rake release:validate` | Check release preconditions before edits; exit nonzero on failure. |
| `prepare` | String | `bundle exec rake release:prepare` | Prepare release files before version resolution and testing. |
| `test` | String | `bundle exec rake` | Test prepared release files before publication. |
| `publish` | String | `bundle exec rake release:publish` | Commit, build, tag, publish to RubyGems, push atomically, and create a GitHub Release through the configured callback. |
| `bump` | String | `bundle exec rake release:bump` | Prepare, commit, and push the next development iteration through the configured callback. |
| `success` | String | `bundle exec rake release:success` | Run after publication and the next development iteration succeed. |
| `failure` | String | `bundle exec rake release:failure` | Run after a release job failure, after Ruby setup. |
| `git-user-name` | String | `github-actions[bot]` | Checkout-local author name for release and next development iteration commits. |
| `git-user-email` | String | `github-actions[bot]@users.noreply.github.com` | Checkout-local author email for release and next development iteration commits. |
| `dry-run` | Boolean | `false` | Check release prerequisites, such as RubyGems Trusted Publishing, without editing files, pushing, or publishing. See [Dry Run](#dry-run). |
| Input | Type | Default | Behavior |
| --- | --- | --- | --- |
| `ruby-version` | String | Required | Ruby version used for validation and building. |
| `version` | String | Empty | Selected numeric `MAJOR.MINOR.PATCH` release version, without leading zeros. Overrides the checked-in version in standard preparation. |
| `gemspec` | String | Empty | Specification path, defaulting to the only root gemspec. Missing or ambiguous specifications fail. |
| `gemfile` | String | `Gemfile` | Gemfile Bundler installs and every release step runs in, set as `BUNDLE_GEMFILE` before Ruby setup. See [Release Gemfile](#release-gemfile). |
| `rubygems-owner` | String | Empty | Numeric RubyGems account ID required for a new gem's pending trusted publisher to create it. |
| `timezone` | String | `UTC` | Installed timezone identifier for the release calendar date and Git timestamp offsets. |
| `prepare-artifacts` | String | Empty | Trusted command preparing explicitly selected input archives after setup, before capture. |
| `artifacts` | String | Empty | Additional newline-separated artifact paths preserved before publication, alongside default paths. |
| `validate` | String | `bundle exec rake release:validate` | Check release preconditions before edits; exit nonzero on failure. |
| `prepare` | String | `bundle exec rake release:prepare` | Prepare release files before version resolution and testing. |
| `test` | String | `bundle exec rake` | Test prepared release files before publication. |
| `publish` | String | `bundle exec rake release:publish` | Commit, build, tag, publish to RubyGems, push atomically, and create a GitHub Release through the configured callback. |
| `bump` | String | `bundle exec rake release:bump` | Prepare, commit, and push the next development iteration through the configured callback. |
| `success` | String | `bundle exec rake release:success` | Run after publication and the next development iteration succeed. |
| `failure` | String | `bundle exec rake release:failure` | Run after a release job failure, after Ruby setup. |
| `git-user-name` | String | `github-actions[bot]` | Checkout-local author name for release and next development iteration commits. |
| `git-user-email` | String | `github-actions[bot]@users.noreply.github.com` | Checkout-local author email for release and next development iteration commits. |
| `dry-run` | Boolean | `false` | Check release prerequisites, such as RubyGems Trusted Publishing, without editing files, pushing, or publishing. See [Dry Run](#dry-run). |

Identity values must be nonempty and contain no line breaks. They change commit attribution, not authentication or push permissions.

Expand Down Expand Up @@ -79,6 +80,20 @@ Expose a string `version` input in the caller's `workflow_dispatch` form and for

Custom preparation commands and callbacks must honor the selection; resolution rejects a mismatched prepared gemspec before publication. Custom version objects must implement `read`, `set!`, and `increment!`. See [UPGRADING.md](../../UPGRADING.md) for migrations.

### Release Gemfile

To keep `ruby-gem-release` and its optional dependencies out of every contributor's and CI variant's bundle, put them in a separate Gemfile that evaluates the main one, and pass it as `gemfile:`:

```ruby
# gemfiles/release.gemfile
eval_gemfile '../Gemfile'

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

The workflow sets `BUNDLE_GEMFILE` for the whole job before `ruby/setup-ruby` installs the bundle, so the built-in `bundle exec rake release:workflow:*` steps and the default commands, including the `test` command's full suite, run in that bundle. Commit or ignore the lockfile Bundler writes next to the selected Gemfile: capture rejects an untracked lockfile as an unclean checkout. Guard the release task setup in your Rakefile with `rescue LoadError` so the main bundle can still load it without the gem.

### Timezone

Set `timezone: America/New_York` under `with:` to use Eastern Time, including daylight saving changes. UTC remains the default.
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby-gem-release/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module RubyGemRelease
VERSION = '0.8.1'
VERSION = '0.9.0'
end
25 changes: 25 additions & 0 deletions spec/workflow_interfaces_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ def run_step(id, directory:, command: '')
expect(workflow.dig('jobs', 'release', 'env', 'TZ')).to eq('${{ inputs.timezone }}')
end

it 'installs and runs every job in the selected Gemfile', :aggregate_failures do
expect(workflow.fetch(true).dig('workflow_call', 'inputs', 'gemfile')).to include('type' => 'string', 'default' => 'Gemfile')
%w[preflight release].each do |job|
expect(workflow.dig('jobs', job, 'env', 'BUNDLE_GEMFILE')).to eq('${{ inputs.gemfile }}')
end
end

it 'runs only the prerequisite checks in the release environment for a dry run', :aggregate_failures do
expect(workflow.dig(true, 'workflow_call', 'inputs', 'dry-run')).to include('type' => 'boolean', 'default' => false)
expect(workflow.dig('jobs', 'release', 'if')).to eq('${{ !inputs.dry-run }}')
Expand Down Expand Up @@ -157,6 +164,24 @@ def run_step(id, directory:, command: '')
it 'passes the configured timezone to input configuration' do
expect(steps.find { |step| step['id'] == 'configure_release_inputs' }.dig('env', 'TZ')).to eq('${{ inputs.timezone }}')
end

it 'exports a selected Gemfile before Ruby setup and rejects multiline values', :aggregate_failures do
selection = steps.find { |step| step['id'] == 'select_gemfile' }
expect(selection.fetch('if')).to eq("${{ inputs.gemfile != '' }}")
expect(steps.index(selection)).to be < steps.index { |step| step['id'] == 'setup_ruby' }
Dir.mktmpdir do |directory|
environment = File.join(directory, 'environment')
File.write(environment, '')
values = ENV.to_h.slice('PATH').merge('GITHUB_ENV' => environment, 'RELEASE_GEMFILE' => 'gemfiles/release.gemfile')
_output, error, status = Open3.capture3(values, 'bash', '-euo', 'pipefail', '-c', selection.fetch('run'), unsetenv_others: true)
expect(status.success?).to be(true), error
expect(File.read(environment)).to eq("BUNDLE_GEMFILE=gemfiles/release.gemfile\n")
_output, error, status = Open3.capture3(values.merge('RELEASE_GEMFILE' => "Gemfile\nINJECTED=1"), 'bash', '-euo', 'pipefail', '-c', selection.fetch('run'), unsetenv_others: true)
expect(status.success?).to be(false)
expect(error).to include('single line')
expect(File.read(environment)).to eq("BUNDLE_GEMFILE=gemfiles/release.gemfile\n")
end
end
end

it 'pins every external action and reusable workflow to a commit with its version as a comment', :aggregate_failures do
Expand Down
Loading