Skip to content

Repair the release workflow#12

Merged
lnsp merged 2 commits into
masterfrom
fix-release-workflow
Jul 25, 2026
Merged

Repair the release workflow#12
lnsp merged 2 commits into
masterfrom
fix-release-workflow

Conversation

@lnsp

@lnsp lnsp commented Jul 25, 2026

Copy link
Copy Markdown
Member

Why

v4.3.0 was tagged and pushed five months ago but never produced a release — the last published release is v4.2.1. The run failed on its very first step, Set up Go 1.21, so the release and homebrew jobs never started.

The workflow was pinned to actions/setup-go@v1, actions/checkout@v1 and the archived actions/create-release / actions/upload-release-asset, all of which run on Node runtimes GitHub has retired. It also asked for Go 1.21 while go.mod now requires 1.24.

What changed

  • Current actions (checkout@v4, setup-go@v5), with the Go version read from go.mod so the two cannot drift apart again.
  • Publish with gh release create rather than the archived release actions — no third-party action needed.
  • Run build, vet and test on pushes and pull requests. The repository has tests now and nothing was running them.

The version was never being stamped

The workflow set -X valar/cli/cmd.version, but the module is github.com/valar/cli. The linker silently ignores -X for a symbol that does not exist, so the variable stayed empty in every published binary — and because rootCmd.Version was empty, cobra never registered a --version flag at all. Verified locally against this branch:

$ go build -ldflags "-X github.com/valar/cli/cmd.version=v4.4.0" -o valar . && ./valar --version
Valar CLI v4.4.0

$ go build -ldflags "-X valar/cli/cmd.version=v4.4.0" -o valar . && ./valar --version
Error: unknown flag: --version

A Verify the version was stamped step now asserts the built binary reports the tag before anything is published, so this cannot regress silently.

Homebrew job

Two latent bugs that would have fired the first time it actually ran:

  • awk ... Formula/valar.rb > Formula/valar.rb — the shell truncates the file before awk opens it, destroying the formula. Now written via a temporary file.
  • sha256sum - emits <hash> -, and the trailing - was being substituted into the formula. Now takes the first field.

Also replaces the deprecated ::set-output, and skips the commit when the formula is already current instead of failing on an empty commit.

lnsp added 2 commits July 25, 2026 17:49
The v4.3.0 tag never produced a release: the run failed on "Set up Go
1.21" and the release and homebrew jobs never started. The workflow was
pinned to actions/setup-go@v1, actions/checkout@v1 and the archived
actions/create-release, all of which run on Node runtimes GitHub has
retired, and it asked for Go 1.21 while go.mod now requires 1.24.

Move to current actions, take the Go version from go.mod so the two
cannot drift again, and publish with the gh CLI instead of the archived
release actions.

Correct the ldflags path while here. It set -X valar/cli/cmd.version, but
the module is github.com/valar/cli, and the linker silently ignores -X
for a symbol that does not exist. Every released binary therefore had an
empty version string, which left cobra without a --version flag at all. A
new step asserts the built binary reports the tag before publishing.

Fix two latent bugs in the homebrew job that would have fired the first
time it ran: it redirected awk into the same file it was reading, which
truncates the formula before awk opens it, and it embedded the trailing
" -" of sha256sum output into the formula.

Also run build, vet and test on pushes and pull requests. The repository
has tests now and nothing was running them.
checkout@v4 and setup-go@v5 target Node 20, which GitHub has deprecated
and is already force-running on Node 24. Node 20 reaching end of life on
the runners is the same bit-rot that broke this workflow before.
@lnsp
lnsp merged commit e251281 into master Jul 25, 2026
3 checks passed
@lnsp
lnsp deleted the fix-release-workflow branch July 25, 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.

1 participant