Skip to content

Homebrew install: brew install p10node/tap/k10s - #29

Merged
junior merged 8 commits into
p10node:mainfrom
junior:homebrew-tap
Nov 9, 2026
Merged

junior merged 8 commits into
p10node:mainfrom
junior:homebrew-tap

Conversation

@junior

@junior junior commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Refs #26. Everything in the issue that is code is here. The rest is at the end: the tap repository, which now exists, and the secret, which needs an admin.

Commit 1 adds packaging/homebrew/formula.sh. Given a tag and that release's checksums.txt, it prints Formula/k10s.rb, which installs the prebuilt macOS and Linux archives (arm64 and amd64) with the sha256 that checksums.txt lists for each: no Go, seconds to install. just brew-formula <tag> <checksums.txt> runs it. It refuses a tag that is not vMAJOR.MINOR.PATCH, and a manifest that does not list each archive exactly once with a well-formed digest. A test-only package beside the script runs it in CI.

Commit 2 adds .github/workflows/homebrew.yml, callable with a tag (workflow_call) and runnable by hand with one (workflow_dispatch). Before it writes anything it checks the tag, that the release is published and is neither a draft nor a pre-release, and each archive against checksums.txt and against the build provenance attestation release.yml signed for that tag. It never moves the tap backwards (the version the tap already has is a no-op), then commits k10s <version> to the tap's main and pushes it with HOMEBREW_TAP_TOKEN, which is used for the tap checkout and the push and nothing else. The workflow token is contents: read and attestations: read.

Commit 3 calls it from release.yml after the release job, for full releases only. Without the secret the job leaves a notice instead of failing, so this can merge before the secret exists.

Commit 4 makes k10s update and /update step aside for a binary inside a Homebrew keg (Cellar/k10s/<version>/, symlinks resolved, matched as whole path segments). k10s update prints k10s: installed by Homebrew, which updates it: run brew upgrade k10s and exits 1 without checking for a release or writing anything, /update shows the same line, and the daily notice names brew upgrade k10s instead of /update. Apply itself refuses a keg before it writes anything, and a test pins that it refuses before its writability probe. update.disabled and /update skip are unchanged.

Commit 5 documents it: the README, docs/install.md (with tap trust, as Homebrew documents it: the full name trusts the formula by itself, the short name and a Brewfile need a trust step), docs/update.md, and docs/maintaining.md (the workflow and the secret).

Checked:

  • gofmt, go vet and go test pass on Go 1.26.10 and 1.27.3 on top of chore(deps): bump the kubernetes group across 1 directory with 6 updates #20 and chore(deps): bump the charm group across 1 directory with 2 updates #21, and the full go test ./... passes on 1.27.3. Taking out any one of the new guards makes its test fail.
  • actionlint 1.7.12, with shellcheck 0.11.0, finds nothing in the three workflows. The steps' shell, run against fixtures, passes 30 checks: tag validation, version comparison (0.1.10 after 0.1.9 included), checksums, and a push to a local repository.
  • The gh attestation verify command the workflow runs passes for the four v0.1.8 archives, and fails with a wrong --source-ref.
  • formula.sh prints byte-identical output under bash 3.2.57, bash 5.3 and zsh 5.9, and shellcheck has nothing to say about it. The test that compares bash with zsh skips where zsh is not installed, which includes GitHub's Ubuntu runners, so that part was checked by hand.
  • The v0.1.8 formula on Homebrew 7.0.12: brew style finds no offenses, brew audit --strict --online is clean for macOS and Linux, arm and intel, and with --new, and brew livecheck finds 0.1.8.
  • The formula's install and test blocks, with a stand-in archive (a shell script that prints a version line): brew install links bin/k10s to Cellar/k10s/0.1.8/bin/k10s, brew test passes, and it fails with a wrong version. The real release binary was not run.

Outside the code:

  1. The tap repository is done: https://github.com/p10node/homebrew-tap has a README and the v0.1.8 formula that commit 1 generates, so brew install p10node/tap/k10s works now. v0.1.8 predates commit 4, so a v0.1.8 installed with brew still updates itself over its keg until the next release replaces it; brew upgrade puts that right.
  2. The secret. Repository secrets need an admin. @pierreneter, could you create a fine-grained personal access token (resource owner p10node, repository access to p10node/homebrew-tap only, Contents: read and write) and add it to this repository as HOMEBREW_TAP_TOKEN? If the organization only allows fine-grained tokens after approval, it needs approving there too.

After that the next full release updates the tap by itself, and homebrew can be run by hand for a tag it missed. Once a release with commit 4 is in the tap and brew install p10node/tap/k10s has been tried on a Mac and on Linux, #26 can close.

packaging/homebrew/formula.sh takes a release tag and that release's
checksums.txt and prints Formula/k10s.rb for p10node/homebrew-tap: the
prebuilt macOS and Linux archives, arm64 and amd64, each with the sha256
that checksums.txt lists for it, so brew install takes seconds and needs
no Go. `just brew-formula <tag> <checksums.txt>` runs it.

It refuses anything but a full release tag (vMAJOR.MINOR.PATCH), and a
manifest that does not list each archive exactly once with a well-formed
digest. The formula has no version line: Homebrew reads the version out
of the release URLs, and brew audit --strict calls such a line
redundant. Its livecheck follows the latest GitHub release, and its test
checks that k10s --version names the version.

The script gives the same output under bash 3.2 and zsh. A test-only Go
package next to it runs it against a fixture manifest, so a change to
the script, or to the archive names it reads, fails a pull request
rather than the tap. Its comparison with zsh skips where zsh is not
installed, as on GitHub's Ubuntu runners, so bash 3.2 and zsh were
checked by hand.

Refs p10node#26

Signed-off-by: Adao Oliveira Jr <[email protected]>
homebrew.yml writes Formula/k10s.rb for a release and pushes it to
p10node/homebrew-tap. release.yml calls it (next commit), and it can be
run by hand with a tag, to publish a release the tap missed.

Before it writes anything it checks that the tag is a full release tag
(passed through env, never into a script), that its release is published
and is neither a draft nor a pre-release, and that each of the four
archives matches checksums.txt and carries the build provenance
attestation release.yml signed for that tag (gh attestation verify with
--signer-workflow, --source-ref and --deny-self-hosted-runners). It
never moves the tap backwards: the version the tap already has is a
no-op, and an older one leaves a warning.

HOMEBREW_TAP_TOKEN, a fine-grained token with Contents read and write on
the tap and nothing else, is used for the tap checkout and the push
only, and neither checkout keeps credentials. The workflow token reads
contents and attestations, nothing more. Without the secret, a run from
a release leaves a notice and changes nothing; a run by hand fails.

Refs p10node#26

Signed-off-by: Adao Oliveira Jr <[email protected]>
A job after the release job calls homebrew.yml with the tag. A
pre-release tag (one with a hyphen) skips it. Until HOMEBREW_TAP_TOKEN
is set the job only leaves a notice, so merging this before the secret
exists cannot fail a release, and the release, published by then,
stands even when updating the tap fails.

Refs p10node#26

Signed-off-by: Adao Oliveira Jr <[email protected]>
A binary that Homebrew installed sits in a keg, Cellar/k10s/<version>/,
and Homebrew keeps a record of the version it put there. k10s update and
/update wrote the new release over it, which left the keg holding a
build Homebrew knows nothing about.

internal/update now recognises a keg: os.Executable with symlinks
resolved (macOS reports the bin/k10s link, Linux the keg itself),
matched as whole path segments, so neither a directory that only has
"Cellar" in its name nor the plain file install.sh puts in
/opt/homebrew/bin counts as one. For a keg:

- k10s update prints "installed by Homebrew, which updates it: run brew
  upgrade k10s" and exits 1, without checking for a release or writing
  anything;
- /update, and the status-bar badge, show the same line instead of the
  install dialog;
- the daily notice names brew upgrade k10s instead of /update, and
  /version says that Homebrew installed it.

update.disabled and /update skip work as before. Apply refuses a keg
too, before its writability check puts a temporary file in the
directory, so no way into the install can write there; a test pins that
order.

Refs p10node#26

Signed-off-by: Adao Oliveira Jr <[email protected]>
README, docs/install.md and docs/update.md: brew install
p10node/tap/k10s, brew upgrade k10s, what k10s update and /update do on
a Homebrew install, and what to do when coming from install.sh, whose
copy in /usr/local/bin or /opt/homebrew/bin stops brew at the link step.

Tap trust as Homebrew documents it (https://docs.brew.sh/Tap-Trust):
since Homebrew 6.0.0 a formula from a third-party tap loads only once it
is trusted. Installing by the full name trusts that one formula by
itself; the short name needs brew trust --formula p10node/tap/k10s
first, and a Brewfile entry needs trusted: true.

docs/maintaining.md describes homebrew.yml and the HOMEBREW_TAP_TOKEN
secret: what it holds, what happens without it or once it expires, and
how to run the workflow again for a tag. docs/dev.md points there.

Refs p10node#26

Signed-off-by: Adao Oliveira Jr <[email protected]>
v1.4.0 read like a planned version. The workflow's input descriptions,
the Justfile and formula.sh's usage comments now say vX.Y.Z, and the
workflow's error for a bad tag names only the pattern. formula.sh's test
fixture uses v9.9.9, like the update tests: the script refuses a tag
that is not a version, so a placeholder cannot stand in there.

Refs p10node#26

Signed-off-by: Adao Oliveira Jr <[email protected]>
p10node#28 adds a sentence after the same table, so the two pull requests
conflicted in docs/maintaining.md. Above the table, both apply in
either order.

Signed-off-by: Adao Oliveira Jr <[email protected]>

@pierreneter pierreneter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together. I've added the HOMEBREW_TAP_TOKEN secret to the repo, so feel free to merge.

@junior
junior merged commit 838e5d6 into p10node:main Nov 9, 2026
3 checks passed
@junior
junior deleted the homebrew-tap branch November 11, 2026 03: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.

2 participants