ci: make the pull request title the release contract - #2
Merged
Conversation
The release automation read the individual commits, but this repository squash merges, so a merge writes ONE commit to main and its subject is the pull request title. The individual commits never reach main, so they cannot decide the release. Pull request #1 showed the cost. It carried seven commits, four of them `fix:`, and it merged under the title: chore: publish as @cornerstonejs/jpeg-lossless-decoder-js (#1) `chore` releases nothing, so the release workflow published nothing. The run still reported success, because "nothing to release" is a legitimate green outcome, and `publish` and `github-release` simply skipped. Only the registry showed that 2.3.0 never existed. This commit makes the title the contract, and makes the contract visible before a merge rather than after it. - tools/conventional.mjs now holds the rules. tools/version.mjs and the new tools/check-pr-title.mjs both read it, so the check and the release cannot disagree about what a subject means. - tools/check-pr-title.mjs rejects a title that is not a conventional subject, rejects an unknown type, rejects a description under 10 characters (the description becomes the CHANGELOG entry), and otherwise states the release the title will produce. - .github/workflows/pr-title.yml runs the check on opened, edited, synchronize and reopened. `edited` matters as much as `opened`: the title is what merges, so a title corrected after review has to be re-checked. - README.md documents the contract as a table of titles, and it records how this package was bootstrapped rather than telling a reader to repeat steps that are done. The title reaches the check through the environment, never through the run script's text. A title is attacker-controlled on a fork pull request, and `${{ ... }}` interpolation would paste it into the shell, so a title containing `$(...)` would execute. Verified: `PR_TITLE='fix: $(touch /tmp/pwned) ...'` is read as literal text and nothing runs. Verified: the lint passes, all 54 tests pass, version.mjs behaves as before after the refactor, and the check gives the right answer for nine titles, including `feat!:` as major, `chore:` as no release, a title with no prefix, an unknown type, and a description that is too short. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The release automation read the individual commits, but this repository squash
merges. A squash merge writes one commit to
main, and its subject is thepull request title. The individual commits never reach
main, so they cannotdecide the release.
Pull request #1 showed the cost. It carried seven commits, four of them
fix:,and it merged under this title:
chorereleases nothing, so the release workflow published nothing:The run reported success, because "nothing to release" is a legitimate
green outcome. Only the registry showed that 2.3.0 never existed. That is the
same trap as a green workflow whose bench job skipped: a run-level success does
not mean the job you care about ran.
What this changes
The title becomes the contract, and the contract becomes visible before a
merge rather than after it.
tools/conventional.mjstools/check-pr-title.mjs.github/workflows/pr-title.ymlREADME.mdtools/version.mjsnow imports the rules instead of holding its own copy, sothe check and the release cannot disagree about what a subject means.
The check fails a title that is not a conventional subject, fails an unknown
type, and fails a description under 10 characters — the description becomes the
CHANGELOG entry, so it has to say what changed. Otherwise it reports the
outcome:
It runs on
opened,edited,synchronizeandreopened.editedmattersas much as
opened: the title is what merges, so a title corrected afterreview has to be re-checked, or a stale pass sits on a title nobody checked.
The contract
feat!: …, or aBREAKING CHANGE:footerfeat: …fix: …,perf: …build:,chore:,ci:,docs:,refactor:,revert:,style:,test:Check one locally:
node tools/check-pr-title.mjs "fix: decode the last sample of a scan"Script injection
The title reaches the check through the environment, never through the run
script's text. A title is attacker-controlled on a fork pull request, and
${{ ... }}interpolation would paste it into the shell, so a title that holds$(...)would execute. Verified — this title is read as literal text andnothing runs:
This pull request releases nothing, on purpose
ci:is the accurate type: the change addstools/and.github/files, andtools/is not in the package'sfilesarray.README.mdis published, so thetarball does change, but a documentation change is not a release of the
decoder.
That does leave the publish path still unproven end to end — nothing has yet
published through OIDC trusted publishing. Two honest ways to prove it:
feat: …before merging, which releases 2.3.0.The check reports the change as soon as the title is edited;
fix:orfeat:prove it.I did not inflate the type to force a release, because that would undermine the
contract this pull request adds.
Verified
tools/version.mjsbehaves as before the refactor.feat!:asmajor,
chore:as no release, a title with no prefix, an unknown type, and adescription that is too short.
🤖 Generated with Claude Code