ci: build and publish brainless as the rolling latest release #18
No reviewers
Labels
No labels
code-review
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
sam/brainless!18
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/ci-build-release"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds
.forgejo/workflows/build.yml: on every push tomainit builds./cmd/brainless(CGO_ENABLED=0,-trimpath -ldflags '-s -w'-> static, ~37 MB) and publishes the binary as the repository's single rollinglatestrelease.Only one artifact is ever kept. Each successful build deletes the previous
latestrelease — and with it the git tag — and then creates the release again at the pushed commit, attaching the binary. That is what keeps the Raspberry Pi running Forgejo from accumulating one binary per push. The delete happens after the build succeeded and before the new release exists, so a failed build never leaves a stale artifact that looks current. The download URL is stable:Why plain
git cloneinstead ofactions/checkout:runs-on: linuxis thelinux:hostlabel of the runner configured insam/pi-deploy(data/runner/runner-config.yml), so steps run directly inside theforgejo-runnercontainer. That image is Alpine plus git, bash and dumb-init — no Node.js — so JavaScript actions such asactions/checkoutcannot run there. The clone authenticates with the automaticFORGEJO_TOKEN(masked in the log) and is--depth 1.Dependency on a runner image change: the same container must provide the Go toolchain, curl and jq. That is the companion PR against
sam/pi-deploy(feat/runner-go-toolchain), which needs an operator to rebuild the runner once:Until that rebuild happens the job fails at the build step with
go: not found.workflow_dispatchis enabled so the pipeline can be re-run without pushing a commit.What was verified, and what was not
I could not run the pipeline itself: the runner container is still the old image (no
go, nocurl, nojq), so the job would stop at the build step withgo: not found. What I could test, I tested.Verified locally:
CGO_ENABLED=0 go build -trimpath -ldflags '-s -w' -o brainless ./cmd/brainlesson thego1.27.1toolchain produces a 37,683,360-byte static executable that runs (-hprints its usage).Verified against this live Forgejo instance: the publish step was extracted verbatim from
build.ymland run four times against a throwaway tag (ci-verbatim-smoke), with a local stand-in forjqbecause this container has nojqinstalled. Results:404-> release created, asset uploaded, stable download URL printed204-> recreated92a6dda->ec6cfd9, releasetarget_commitishfollowed, exactly one release and one asset in the repositoryHTTP 200, 37,683,360 bytes, byte-identical to the uploaded fileThat last row is what caught a real bug.
DELETE /repos/{owner}/{repo}/releases/tags/{tag}deletes the release but leaves the git tag, and a release created for a tag that already exists keeps that tag's commit and ignorestarget_commitish. Without deleting the tag as well, the very first build would have pinnedlatestto its commit permanently while serving newer binaries from it. Fixed inb9831e1: the step now deletesreleases/tags/latestand thentags/latest.The test released a temporary tag and asset; both were deleted afterwards and the repository is back to zero releases and zero tags. My scratch files under
/tmpare removed.Still unverified, and unavoidably so: the runner-side mechanics — whether
runs-on: linuxhost-mode steps get theFORGEJO_*environment variables and the automaticFORGEJO_TOKEN, whether the default shell really is bash, and whether that token may create releases. All of it is documented in the Forgejo Actions reference, none of it can be exercised before the runner image is rebuilt. Once it is:the job can be triggered from this branch without merging, via the Actions tab or:
End-to-end evidence from a real run on the branch
I dispatched
build.ymlatfeat/ci-build-release(run 120,workflow_dispatch). It fails on purpose, and it fails usefully — this is the raw log:What that establishes, none of which could be confirmed by reading documentation alone:
120withjobs: ["build"], so the job and itsruns-on: linuxlabel were understood.FORGEJO_TOKENauthenticated over the internal URL,FORGEJO_REF_NAME/FORGEJO_REPOSITORY/FORGEJO_SERVER_URLare all populated in host-mode steps, and--depth 1 --branchchecked out the pushed commit (b9831e1). This was the biggest open question, since plaingit clonereplacedactions/checkout.sh: the Forgejo runner spawns run steps asbash --noprofile --norc -e -o pipefail <script>, soset -euo pipefailis safe.go: command not foundis reported at line 8 ofworkflow/1.sh— line 8 of the build step's script is exactly itsCGO_ENABLED=0 go build ...line, which confirms the step numbering and that my relative paths (repo/, thenrepo/brainlessfrom the publish step) resolve against the job workspace rather than something left over from the previous step. The runner's host executor uses the job workspace whenever a step declares noworking-directory(act/container/host_environment.go,wd = e.Path).The remaining failure is purely the missing toolchain, and the run is expected to stay red until the runner image is rebuilt:
After that I will dispatch it again to confirm a green run,
latestpointing at the right commit, and the download URL serving the freshly built binary.