Skip to content

ci: validate the tap token before publishing anything - #5

Merged
Arnonrgo merged 1 commit into
masterfrom
ci/preflight-tap-token
Sep 8, 2026
Merged

ci: validate the tap token before publishing anything#5
Arnonrgo merged 1 commit into
masterfrom
ci/preflight-tap-token

Conversation

@Arnonrgo

@Arnonrgo Arnonrgo commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Why

v0.8.1 and v0.8.2 both published complete, correct releases and then failed at the same place:

homebrew cask: could not get default branch:
  GET https://api.github.com/repos/mondaycom/homebrew-tap: 401 Bad credentials

HOMEBREW_TAP_TOKEN is now set as a secret, so the value itself is what GitHub is rejecting — 401 Bad credentials means the credential is invalid outright (expired, revoked, or pasted incompletely), as distinct from a 404 for a valid token lacking access to that repo.

The expensive part isn't the bad token, it's that discovering it costs a version each time. Releases here are immutable and the cask pipe runs after the release pipe, so by the time the cask fails there's a published release that can never receive one, and re-running is refused. Two versions burned to learn the same fact.

What this does

Checks the token before the release exists. On failure the job stops in seconds having published nothing — so fixing the secret and re-running is enough, with no new tag. It also catches a token that can read the tap but not push to it, which would otherwise fail later at exactly the same unrecoverable point.

Also bumps flake.nix to 0.8.3, which the version guard from #4 requires.

Verification

Exercised all four paths locally:

Token Result
unset HOMEBREW_TAP_TOKEN is not set.
invalid cannot read mondaycom/homebrew-tap -- gh: Bad credentials (HTTP 401)
valid, no access cannot read ... -- gh: Not Found (HTTP 404)
valid tap token can push to mondaycom/homebrew-tap

The invalid case reproduces the exact error the two releases hit. gh prints its one-line summary to stderr and the raw JSON body to stdout, so the annotation reads stderr — reading stdout instead yields a useless {.

nix build .#mclimcli version 0.8.3.

Before tagging v0.8.3

The token still needs fixing — this PR only ensures a bad one fails cheaply. Worth checking it hasn't expired and that it grants Contents: read and write on mondaycom/homebrew-tap; if it's fine-grained, an org-owned repo may also need approval from an org admin.

🤖 Generated with Claude Code

Both v0.8.1 and v0.8.2 published complete releases and then failed at the
cask with `401 Bad credentials` on mondaycom/homebrew-tap. Because releases
here are immutable and the cask pipe runs after the release pipe, neither
could be repaired -- each attempt cost a version to discover the same
broken credential.

Check the token before the release exists. If it cannot read the tap, or
can read but not push, the job stops in seconds having published nothing,
so fixing the secret and re-running is enough; no new tag needed. gh puts a
one-line summary on stderr and the JSON body on stdout, so the annotation
reports stderr -- 401 distinguishes an invalid or truncated token from a 404
for a token with no access to the repository.

Bumps flake.nix to 0.8.3, which the preceding version guard requires.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Arnonrgo
Arnonrgo merged commit 113b306 into master Sep 8, 2026
3 checks passed
@Arnonrgo
Arnonrgo deleted the ci/preflight-tap-token branch September 8, 2026 18:21
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.

1 participant