Skip to content

fix(release): publish and verify the versioned spored before GoReleaser makes the CLI installable (#1415) - #1417

Merged
scttfrdmn merged 3 commits into
mainfrom
fix/1415-publish-spored-first
Oct 29, 2026
Merged

scttfrdmn merged 3 commits into
mainfrom
fix/1415-publish-spored-first

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1415

With #1412 (PR #1416), a release spawn installs spored only from spawn/versions/<ver>/ and retires the instance if it is missing. release.yaml uploaded those objects after GoReleaser had already published the CLI, the tap and the Scoop bucket. This PR publishes and verifies them before GoReleaser runs, the same way the bootstrap body is already handled.

How it works

GoReleaser OSS has no build-then-publish split. I checked against v2.19.0, the current ~> v2: the commands are build, check, release and so on, with no publish or continue. release --skip=publish cannot be followed by a step that publishes the prepared dist/. --split/--prepare, continue/publish and the prebuilt builder are all Pro-only. So the workflow builds spored itself and checks afterwards that GoReleaser built the same bytes.

New step order in job goreleaser:

  1. AWS creds, then "Publish the bootstrap body to S3" (unchanged).
  2. Build spored for the release: CGO_ENABLED=0 GOOS GOARCH go build -ldflags "-s -w -X main.Version=${VERSION}" -o $RUNNER_TEMP/spored-release/<name> ./cmd/spored for linux/amd64, linux/arm64 and windows/amd64. This is exactly the spored build in .goreleaser.yaml. The output goes outside the checkout.
  3. Publish the versioned spored to S3:
    • KMS-signs each binary's digest.
    • Verifies each .sig with openssl against the key compiled into the tagged spawn, using a new hidden spawn spored-signing-key command, modeled on bootstrap-body. A wrong SPORED_SIGNING_KEY_ID now fails here, before anything is published.
    • Uploads the binary, .sha256 and .sig to spawn/versions/${VERSION}/ in all 11 buckets.
    • SPORED_SIGNING_KEY_ID is now required, as it already was for the body. The sha256-only fallback is removed.
  4. Verify the published versioned spored: downloads all 99 objects (11 buckets x 9 objects) and cmps each one against the local file.
  5. Run GoReleaser, then "Check the released spawn prints the published body" (unchanged).
  6. Check GoReleaser built the published spored (id: spored-dist-match, if: !cancelled()): the sha256 of each dist/spored_* must equal the published .sha256. On any mismatch or missing file it fails with ::error::.
  7. Attest (unchanged).
  8. AWS creds, then Update the latest spored. Both steps have if: !cancelled() && steps.spored-dist-match.outcome == 'success'. The step also requires gh release view $TAG --json isDraft to report false. It then copies the already-verified files to spawn/spored-* and to the bucket-root spored-*, the same keys as before. Nothing is rebuilt or re-signed.

When latest moves

The unversioned latest copies are what releases before #1412 and dev builds install. They move only once this release is actually published and its spored matched, so latest never points at a release that failed. The step is deliberately not gated on GoReleaser's own success. An expired tap token (spawn#280) fails GoReleaser after the GitHub release is already up, and latest should still move then, as it did before.

Reproducibility evidence

.goreleaser.yaml's spored build:

  • has no -trimpath, so absolute paths are embedded. Both builds run in the same $GITHUB_WORKSPACE with the same setup-go toolchain, so the paths are identical.
  • uses mod_timestamp, which sets only the file mtime, not the content.
  • uses default buildvcs, which stamps vcs.revision, vcs.time and vcs.modified.

Before GoReleaser the tree is clean, because the body and spored go to $RUNNER_TEMP. During GoReleaser it stays clean, because dist/ and the before-hook outputs are gitignored (gated by TestReleaseBuildLeavesTheTreeClean, #1266).

Measured locally with go1.27.3:

  • goreleaser build --snapshot --clean --skip=before --id spored (v2.19.0) and the workflow's exact go build loop, with the same version string, gave identical sha256 for all three targets: amd64 258675de…, arm64 44c1c210…, windows f57f338f….
  • go version -m shows the same -ldflags, CGO_ENABLED=0, GOAMD64=v1 and vcs.modified=false.
  • Adding one untracked file to the tree changed the hash (c2eece2e…). So the output must stay outside the checkout; a test gates that, and the post-GoReleaser check would also catch it.

Release-role IAM needed (GitHubActions-spore-host-release, inline SpawnBinariesS3Upload)

  • New: s3:GetObject on arn:aws:s3:::spawn-binaries-*/spawn/versions/*, for the read-back in "Verify the published versioned spored". I can't see the hand-managed policy, so this may already be granted. If it is missing, the verify step fails before GoReleaser, so the release stops with no CLI published. That is safe, but the release is blocked: apply this before tagging.
  • s3:PutObject is unchanged. The object keys are the same as before: spawn/versions/<v>/spored-{linux-amd64,linux-arm64,windows-amd64.exe}{,.sha256,.sig}, spawn/spored-*{,.sha256,.sig} and the bucket-root spored-*{,.sha256,.sig}.
  • kms:Sign is unchanged.
  • gh release view uses the job's GITHUB_TOKEN (contents: write, already granted).
  • Cost: the read-back pulls about 2.2 GB (3 binaries x about 65 MB x 11 regions), roughly $0.20 of S3 egress and a minute or two per release. The copies are deleted after the check.

What to check on the next real release

  • The run log step order: body publish, then "Build spored for the release", then "Publish the versioned spored to S3", then "Verify the published versioned spored", then "Run GoReleaser", then "Check GoReleaser built the published spored", then "Update the latest spored".
  • The spawn/versions/<v>/spored-* objects' LastModified times are before the Homebrew tap and Scoop bump commits and the GitHub release creation time.
  • "Check GoReleaser built the published spored" printed ✅. This is the first real proof that the two builds agree on ubuntu-latest.
  • verify-spored.sh passes, with sha and sig checks on the versioned copies and versioned == latest.

Gates (each watched failing against a compiling revert)

All in release_spored_publish_test.go. Each one runs the workflow's own steps under bash with stand-in go/aws/gh, a real P-256 key for the fake KMS, and an S3 mirror. Every revert was a YAML or config edit, so everything still compiled.

Gate Revert Result
TestReleasePublishesTheVersionedSporedBeforeTheCLI (order, unconditional pre-steps, match !cancelled(), latest gated on match outcome) moved the 3 spored steps after GoReleaser; dropped the match step's if; loosened latest's if to !cancelled() all FAIL
TestReleaseBuildsSporedLikeGoReleaser (parses .goreleaser.yaml and the recorded go build invocations: env, ldflags, package, targets, no extra flags, unknown goreleaser keys refused, output outside the checkout) workflow drops -s; adds -trimpath; CGO_ENABLED=1; output to $PWD; goreleaser gains flags:, an extra ldflag, or ignores linux/arm64 all FAIL
TestReleasePublishesTheSignedVersionedSpored (99 objects, sig verifies against the compiled key, no latest before GoReleaser) publish step also writes spawn/spored-* FAIL
TestReleaseRefusesASporedSignatureSpawnWouldReject removed the openssl verify FAIL
TestReleaseVerifyCatchesAMissingOrAlteredSpored removed the cmp FAIL
TestReleaseFailsWhenGoReleasersSporedDiffers removed exit 1 on mismatch FAIL
TestReleaseUpdatesLatestOnlyOnceTheReleaseIsPublished removed the isDraft check FAIL (198 latest objects written for a draft/missing release)

The existing body tests now run the new spored steps. TestOnlyTheReleaseWorkflowPublishesSpored's text check was updated for the new variable-based names, and its behavioural replacement is the gate above.

Checks

From /private/tmp/spawn-1415: make check and make lint (0 issues, 10 modules), semgrep scan --config=auto --error . (0 findings), make check-docs clean (the new command is hidden), and actionlint clean on release.yaml. The three new xargs pipelines carry # shellcheck disable=SC2016; the old step already tripped SC2016 at info level. The repo runs neither actionlint nor zizmor in CI or the Makefile. No new actions; all uses: stay SHA-pinned.

@codecov

codecov Bot commented Oct 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/spored_signing_key.go 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn force-pushed the fix/1415-publish-spored-first branch from b713489 to 18445d0 Compare October 29, 2026 06:21
@scttfrdmn
scttfrdmn merged commit 969ae9c into main Oct 29, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1415-publish-spored-first branch October 29, 2026 06:40
@scttfrdmn scttfrdmn mentioned this pull request Oct 29, 2026
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.

release: publish the versioned spored before the CLI is installable (launches pinned by #1412 retire until it lands)

1 participant