Repository navigation
feat(release): build and package with goreleaser (#502) - #521
Merged
Merged
Conversation
One .goreleaser.yml replaces nfpm.yaml, release.yml's five-cell build
matrix (131 lines) and its package-linux job (274) — the two jobs collapse
into one `artifacts` job of 162 lines. `make package-linux` runs the same
binary over the same config, so what a pull request proves and what a tag
does are the same operation.
The published layout does not change: the same five tarballs under the same
names, each holding the same platform-named binary, each with its own
.sha256 sibling; the same .deb and .rpm filename conventions; the same
twelve install destinations; the same two maintainer scriptlets. Three
goreleaser defaults had to be overridden to keep it that way, and each was
found by building and inspecting rather than by reading docs:
- file_name_template: {{ .ConventionalFileName }} — the default names an
rpm objectfs_0.16.0_linux_amd64.rpm, where amd64 is not what rpm calls
that architecture and _linux_ appears in no rpm anywhere.
- files: [none*] on the archive, not files: [] — an empty list reads as
unset and the defaulter fills it in; measured, all five tarballs came
out carrying CHANGELOG.md, LICENSE and README.md beside the binary.
- checksum: split: true — the default writes one checksums.txt and no
per-asset siblings, and scripts/install.sh fetches <asset>.sha256 by
exact name and treats its absence as fatal.
Two builds of the same source, because goreleaser has no rename step
between a build and an archive: the tarball's binary is named for its
platform (install.sh looks up objectfs-linux-amd64) and the package's has
to be `objectfs` (the systemd unit, both modulefiles and postinstall.sh
invoke it). With a single platform-named build the rpm came out carrying
/usr/bin/objectfs-linux-amd64: it built, installed, ran its scriptlet,
exited 0, and then answered `objectfs: command not found`, with every
packaging test passing because the binary is not a contents: entry.
TestThePackagedBinaryIsOnThePathAsObjectfs is that gate, and it is new.
Publishing stays outside goreleaser (release: disable: true). Three things
the publish job does have no goreleaser equivalent: notes extracted from a
hand-written CHANGELOG.md, a cross-check that the .sha256 files and
checksums.txt agree before either is served, and a cosign verify-blob
against the certificate identity the notes name.
Also removes the GPG signing apparatus, because nothing on any install path
this project publishes ever checked the signature it produced. Both the
config and TestTheRPMSigningPathStaysIntact said "gpgcheck=1 is dnf's
default ... so dnf install ./objectfs-*.rpm checks it too". The first
clause is right and the second does not follow — read out of a rockylinux:9
container rather than reasoned about:
gpgcheck = True # packages from a *repository*
localpkg_gpgcheck = False # a package named as a local file
A deliberately unsigned aarch64 rpm installed with `dnf install ./...rpm`,
pulled fuse3 in as a Recommends, ran its scriptlet, reported
`Signature : (none)` under rpm -qi, and answered `objectfs version`. dnf
raised nothing. The failure that originally motivated the signature was
real and came from ci.yml's repo-install job installing out of a
throwaway-signed *yum repository* — the repository path, governed by the
first setting, and the path deleted in 81d137c. GPG_SIGNING_KEY and
GPG_PASSPHRASE are no longer read by anything.
Two deliberate behavioural changes: armv7 now gets a .deb and an .rpm, so a
release carries 11 assets instead of 9; and -trimpath is passed, which was
not previously true.
ci.yml's packaging job now reads the version it looks for out of
dist/metadata.json rather than out of cmd/objectfs/main.go, because a local
or CI build is a --snapshot: the constant says 0.14.0 while the artifacts
say 0.14.1-next, and the modulefiles install under that string. Verified by
unpacking both a deb and an rpm.
Refs #502
The two are independent templates in .goreleaser.yml and have to be the
same string: wrap_in_directory is false, so the tarball holds one file, and
install.sh looks that file up by name before renaming it to objectfs.
Mutating the build's binary: template from
objectfs-{{ .Os }}-{{ .Arch }}... to objectfs-{{ .Os }} and leaving the
archive's name_template alone passed every test in the package — the release
would download, verify its checksum, and die on "does not contain
objectfs-linux-amd64" on all five platforms at once.
…step `strings.Contains(step, "release")` is true for every step that uses `goreleaser/goreleaser-action`, because "goreleaser" contains "release". The check written to reject `goreleaser build` — which compiles the binaries and produces no archive, no package and no checksum — passed with `args: build --clean` in the file, verified by mutation. actionInput reads one named with: input instead, and a block scalar comes back empty, which fails the caller rather than passing it.
The packaging job failed on PR #521: goreleaser v2.18.1 declares `go >= 1.27.1`, this module declares 1.26.0, and setup-go sets GOTOOLCHAIN=local so the Go it installed is the Go that runs. The Makefile's from-source fallback therefore cannot work in CI — go: github.com/goreleaser/goreleaser/[email protected] requires go >= 1.27.1 (running go 1.26.6; GOTOOLCHAIN=local) — and that refusal is correct: pinning the toolchain is the point, and a job that silently fetched a newer Go to build a release tool would build the release with a compiler this project does not test against. A developer with the default GOTOOLCHAIN=auto never sees it, which is why it reached a pull request instead of this machine. ci.yml now installs a prebuilt goreleaser with goreleaser-action's install-only mode, at the same pin release.yml uses, and still builds with `make package-linux` — so the command a developer runs, the command a pull request runs and the command a tag runs stay the same command over the same config. That makes three copies of the version pin, so TestTheGoreleaserVersionIsPinnedToOneValueEverywhere couples them: goreleaser owns the asset names, so a skew means a PR proved a different tool than the release used. Its first form read every `version:` in the workflows and reported a skew that did not exist — v2.12.2 is golangci-lint's pin. It now reads the input out of the goreleaser-action step that sets it.
…next The comment named the number a developer's full clone produces. actions/ checkout fetches one commit and no tags, so goreleaser finds no tag, falls back to v0.0.0, and incpatch gives 0.0.1-next — which is what the run actually exported through Lmod. Someone debugging the modulefile path would have gone looking for a version this job never builds. Left shallow on purpose, and the comment now says why: nothing here depends on the version being a particular string, only on the packaging, the install and the modulefile agreeing on it, and a number nothing could have hardcoded tests that agreement more strongly. release.yml passes fetch-depth: 0 because there the tag is the version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #502. Second half of the two-PR split; #520 was the first.
One
.goreleaser.ymlreplacesnfpm.yaml,release.yml's five-cell build matrix (131 lines) and itspackage-linuxjob (274). The two jobs collapse into oneartifactsjob of 162 lines, andmake package-linuxruns the same binary over the same config — so what a PR proves and what a tag does are the same operation.The published layout does not change. Same five tarballs under the same names, each holding the same platform-named binary, each with its own
.sha256sibling; same.deb/.rpmfilename conventions; same twelve install destinations; same two maintainer scriptlets.Three goreleaser defaults had to be overridden, each found by building rather than by reading
file_name_template: "{{ .ConventionalFileName }}"— the default names an rpmobjectfs_0.16.0_linux_amd64.rpm, whereamd64is not what rpm calls that architecture and_linux_appears in no rpm anywhere. The override restores each format's own arch spellings (amd64/arm64/armhfvsx86_64/aarch64/armv7hl).files: [none*], notfiles: []— an empty list reads as unset and the defaulter fills it in. Measured: all five tarballs came out carryingCHANGELOG.md,LICENSEandREADME.mdbeside the binary.none*is a glob matching nothing, which is the documented way to say "no extra files".checksum: split: true— the default writes onechecksums.txtand no per-asset siblings.scripts/install.shfetches<asset>.sha256by exact name and treats its absence as fatal, so the default publishes a complete-looking release that breaks the documented one-liner on every platform at once.Two builds of the same source
goreleaser has no rename step between a build and an archive. The tarball's binary is named for its platform (
install.shlooks upobjectfs-linux-amd64and renames it); the package's has to beobjectfs, because that is what the systemd unit, both modulefiles andpostinstall.shinvoke. With a single platform-named build the rpm came out carrying/usr/bin/objectfs-linux-amd64: it built, installed, ran its scriptlet, exited 0, and then answeredobjectfs: command not found— with every packaging test passing, because the binary is not acontents:entry.TestThePackagedBinaryIsOnThePathAsObjectfsis that gate, and it is new.Publishing stays outside goreleaser
release: disable: true. Three things thepublishjob does have no goreleaser equivalent: notes extracted from a hand-written Keep-a-ChangelogCHANGELOG.mdrather than from commit subjects, a cross-check that the per-asset.sha256files andchecksums.txtagree before either is served, and acosign verify-blobagainst the same certificate identity the notes tell a reader to pass.The GPG apparatus is gone, because nothing ever checked the signature it produced
nfpm.yaml'srpm.signatureblock,release.yml's key-import steps andTestTheRPMSigningPathStaysIntactall rested on one claim, stated in those words: "gpgcheck=1is dnf's default and verifies each package's own embedded signature, sodnf install ./objectfs-*.rpmchecks it too." The first clause is right and the second does not follow. Read out of arockylinux:9container rather than reasoned about:A deliberately unsigned aarch64 rpm was installed with
dnf install ./objectfs-0.14.0-1.aarch64.rpm. It installed, pulledfuse3in as a Recommends, ran the postinstall scriptlet, reportedSignature : (none)underrpm -qi, and answeredobjectfs version. dnf raised nothing.The failure that originally motivated the key was real — "Package objectfs-0.13.0-1.x86_64.rpm is not signed / Error: GPG check FAILED" — and it came from
ci.yml'srepo-installjob installing out of a throwaway-signed yum repository withgpgcheck=1. That is the repository path, governed by the first setting, and it is the path #520 deleted:objectfs.io/yumanswered 404 for the whole life of the feature.GPG_SIGNING_KEYandGPG_PASSPHRASEare now read by nothing. Deleting the secrets is a repository-settings change and is left to @scttfrdmn.Two deliberate behavioural changes
.deband an.rpm. nfpm's output is per linux platform and armv7 is already a build target here; the old Makefile loop built amd64 and arm64 only, andrelease.yml's comment recorded that asymmetry as a limitation rather than a decision. A release now carries 11 assets — 5 tarballs, 3 debs, 3 rpms — up from 9.-trimpath, which was not previously passed. It strips the build machine's absolute paths out of the binary, so a build is reproducible from the tag rather than from the runner.Mutation results
14 mutations. 12 were killed by the intended test on the first run. Two survived, and both were real gate defects:
TestTheArchiveNameTemplateIsTheOneEverythingElseAssumespinned the archive'sname_templatebut not the archived binary'sbinary:template. They are independent strings that have to be identical —wrap_in_directory: false, so the tarball holds one file andinstall.shlooks it up by name. Shortening one and leaving the other passed the whole package and would have shipped a release that downloads, verifies its checksum, and then dies on "does not contain objectfs-linux-amd64" on all five platforms at once.goreleaser buildsearched the step body for"release"— which is a substring ofgoreleaser/goreleaser-action.args: build --cleanpassed it. It now reads theargs:input by name.Both are fixed and re-mutated.
Verification
goreleaser checkvalidates;make package-linuxproduces exactly 22 files (11 assets + 11.sha256siblings) with correct conventional names.ar xon the amd64 deb andpodman run rockylinux:9 rpm -qplon the aarch64 rpm both show all twelve destinations,/usr/bin/objectfs, and modulefile paths of0.14.1-next— matchingdist/metadata.json'sversionexactly.gofmt,go vet,golangci-lint run ./internal/config/...clean;go test -race ./internal/config/ok.One CI-visible consequence:
ci.yml'spackagingjob now reads the version it looks for out ofdist/metadata.jsonrather than out ofcmd/objectfs/main.go. A local or CI build is a--snapshot, so the constant says0.14.0while the artifacts say0.14.1-nextand the modulefiles install under that string. Reading the constant would have the job look for a path nothing created and report it as a packaging failure.There are deliberately no
-Xldflags:versionincmd/objectfs/main.gois an untyped constant, so the linker cannot rewrite it, and every release before #375 passed that flag and shipped a binary reporting the hardcoded value anyway.release.ymlstill asserts the tag equals"v"plus the constant, andTestPackageVersionComesFromTheVersionConstantnow fails on a re-added-X main.version.