Skip to content

Add opt-in version check to verify tag matches gem VERSION#29

Open
cseeman wants to merge 1 commit intorubygems:v1from
cseeman:add-version-check
Open

Add opt-in version check to verify tag matches gem VERSION#29
cseeman wants to merge 1 commit intorubygems:v1from
cseeman:add-version-check

Conversation

@cseeman
Copy link
Copy Markdown

@cseeman cseeman commented Mar 17, 2026

Summary

  • Adds a check-version input (default false) that verifies the git tag matches the gemspec version before publishing
  • Handles common tag formats: v1.2.3, bare 1.2.3, and monorepo-style prefixes like my-gem-v1.2.3
  • Skips the check when the workflow is not triggered by a tag push
  • Documents the new input and version check feature in the README

Justification

Prevents accidentally publishing a gem whose version does not match the release tag. This is an opt-in safeguard, so existing workflows are unaffected.

Technical Details

The check loads the gemspec via Gem::Specification.load to extract the version, then strips known tag prefixes (v, monorepo-style name-v or name/v) before comparing. The step only runs when check-version: true and the workflow is triggered by a tag ref.

Closes #14

Add a check-version input (default false) that, when enabled, verifies
the git tag triggering the release matches the version in the gemspec
before publishing. This prevents accidentally pushing a gem whose
version does not match the release tag.

The check handles common tag formats including v1.2.3, bare 1.2.3,
and monorepo-style prefixes like my-gem-v1.2.3 or my-gem/v1.2.3.
When the workflow is not triggered by a tag push, the check is skipped.

Closes rubygems#14
@cseeman cseeman marked this pull request as ready for review March 17, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider adding a check that release / tag matches the published gem VERSION

1 participant