Skip to content

Fix the release workflow's tag check and report a refused release - #46

Open
mwhitham wants to merge 6 commits into
mainfrom
fix/release-tag-check
Open

mwhitham wants to merge 6 commits into
mainfrom
fix/release-tag-check

Conversation

@mwhitham

Copy link
Copy Markdown
Owner

Fixes the release workflow so /release can release 2.1.2. No version change: main stays at 2.1.2, which has no tag yet.

What went wrong

The /release run after #45 failed in "Decide what to release" (run):

v2.1.2 already names commit {"message":"Not Found",...}

For a tag that does not exist, gh api repos/.../git/ref/tags/<tag> exits with status 1 but prints GitHub's "Not Found" body on standard output. The step ignored the exit status (|| true) and read that body as the tag's commit. The "Tag the tested commit" step had the same check, so it would have failed in the same way.

No pull request comment followed, because the report job ran only when the first step had set release to true.

The fix

  • Both tag checks use git/matching-refs/tags/<tag>. It returns an empty list when there is no tag. An annotated tag is followed to its commit. Any other failure, such as an outage, now stops the step instead of being read as "no tag".
  • The decide step refuses a package.json version that is not X.Y.Z, because the version becomes part of the tag.
  • The report job also runs when the decide step fails, so a refused release posts a comment.

Verified

Both edited steps were taken from this workflow file and run with bash -e, as Actions runs them, against this repository. A guard stopped any tag from being created.

Case Result
Decide, main, publish on, no v2.1.2 tag release=true, "Releasing v2.1.2 from 073f9bc…"
Decide, publish off release=false, exit 0
Decide, GitHub error exit 1
Tag, v2.1.2 missing creates the tag (stopped by the guard)
Tag, v2.0.0 already on that commit nothing to do, exit 0
Tag, v2.0.0 on another commit refused, exit 1
Tag, GitHub error exit 1, no tag created

The old decide step, run the same way, reproduces the error above.

Not tested here: an annotated tag (the repository has none), and the report job's new condition, which runs only on GitHub. The next /release is the full test.

cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test (731 tests), and the npm ci, typecheck, and test steps pass.

After merging

  1. Recreate the npm trusted publisher link if it has expired.
  2. Comment /release on this pull request when the bot says 2.1.2 is ready.

🤖 Generated with Claude Code

The first /release run for 2.1.2 stopped in its first step. For a missing
tag, gh api prints GitHub's Not Found body on standard output, and the
step read that body as the commit the tag names. Both tag checks now read
the matching-refs list, which is empty when there is no tag, and stop on
any other failure instead of treating it as no tag.

The report job ran only after the first step set release to true, so the
refused run left no comment on the pull request. It now also runs when
that step fails.

No version change: main is still 2.1.2 with no tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant