Skip to content

feat(self): release channels via go-selfupdate - #11

Merged
bfirestone merged 10 commits into
mainfrom
feat/self-channel
Sep 4, 2026
Merged

bfirestone merged 10 commits into
mainfrom
feat/self-channel

Conversation

@bfirestone

Copy link
Copy Markdown
Contributor

envctl self update followed only the latest stable release, so nobody could opt into a release candidate. It now delegates to github.com/sentiolabs/go-selfupdate v0.1.1 and gains envctl self channel <stable|rc|nightly>. The channel persists in ~/.config/envctl/config.yaml (0600 in a 0700 directory). A newer stable release always wins over an older rc or nightly. internal/cmd/self.go is 41 lines of wiring with no HTTP or semver code.

Two new workflows. prerelease.yml builds v*-rc* and v*-nightly* tags with goreleaser. nightly.yml tags v<next patch>-nightly.<date> at 06:00 UTC when main moved and dispatches the build, since a tag pushed with GITHUB_TOKEN never triggers a workflow.

The root command runs with a signal-aware context, so Ctrl-C aborts a slow secrets fetch. envctl run keeps forwarding signals to its child and removing the run dir.

Verify: make test and make lint. README documents channels and rc tagging. Cutting the first rc tag is a separate decision.

Replaces the hand-rolled GitHub lookup and semver comparison with github.com/sentiolabs/go-selfupdate and adds self channel.
Nightlies are tagged with the next patch version, so they sort above the current release under semver. A nightly tagged with the released version would never be offered.
A tag pushed with the default GITHUB_TOKEN doesn't start a new workflow run. workflow_dispatch is exempt from that rule, so the nightly job dispatches prerelease.yml directly.
Cobra handed every command context.Background(). Its nil Done channel stops exec.Cmd from watching for cancellation, so a cancelled context never reached the install pipeline behind self update. executeRoot exists so the deferred stop runs before os.Exit.
These commands built their own context.Background(), so the root signal handler swallowed Ctrl-C without cancelling the fetch. signalContext now releases the handler once the first signal lands, so a second Ctrl-C kills a command that ignores its context. commandContext falls back to context.Background() because tests call the RunE functions directly.
Calling stop() after the context cancelled did not restore the fatal default, so a second Ctrl-C was swallowed. signalContext now exits with 128 plus the signal number, the status a shell reports for a signal kill.
The root force exit called os.Exit on the second signal, which skipped runRun's deferred cleanup and orphaned the child. The run directory and its secret files were left on disk. Run releases the root handler once its own trap is registered, and the root context still cancels first without effect here.
@bfirestone
bfirestone merged commit 37efe86 into main Sep 4, 2026
3 checks passed
@bfirestone
bfirestone deleted the feat/self-channel branch September 4, 2026 07:46
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