goreleaser — release automation driven offline-first, measured
goreleaser (MIT, ~16k stars) packages a Go (and
Rust/Zig/etc.) repo into cross-compiled binaries, archives, checksums and package formats, and can
publish the lot to GitHub/GitLab/Gitea. Its killer property for iteration is that almost the whole
pipeline runs offline — validate the config, snapshot-build every target, and dry-run a full
release that writes all artifacts into dist/ without touching any remote or token. Everything
below was measured live on the official v2.20.3 release tarball
(goreleaser_Linux_x86_64.tar.gz, sha256 verified against the release's checksums.txt) published
2026-11-20. Exit codes were read unpiped; every trap listed was produced, not quoted.
Install and verify
- Release assets per platform (
goreleaser_Linux_x86_64.tar.gz, arm64/i386/loong64/riscv64 …,.deb/.rpm/.apk/flatpak, pluschecksums.txtand a Sigstore attestationchecksums.txt.sigstore.json). Extracted payload: onegoreleaserbinary,LICENSE.md,README.md,manpages/,completions/. - Checksum-trap:
checksums.txtlists the SBOM sidecar files too (goreleaser_Linux_x86_64.tar.gz.sbom.json). A baregrep 'goreleaser_Linux_x86_64.tar.gz' checksums.txtmatches two lines (the tarball and its sidecar, whose name contains the tarball name as a substring) andsha256sum -c -then exits 1 on the missing sidecar even though the tarball verified OK. Verify the single exact line (see recipe 1). - The single binary is self-contained; the only runtime prerequisites for
buildaregitand a Go toolchain (goreleaser healthcheckprints✓ git/✓ goand exits 0 when both are present). Install it on your PATH (recipe 1 copies to~/.local/bin; add that to PATH if you do not have it yet).
The v2 command set
goreleaser --help exposes exactly: build, check, completion, healthcheck, init,
jsonschema, release (plus help). The v1-era subcommands are gone in v2. check takes
configuration files as positional args; build/release take -f/--config <file> instead.
The offline workflow loop
goreleaser init— scaffold.goreleaser.yaml+dist/into.gitignore(see traps).goreleaser check— validate config. Requires a git repo with a configured remote.goreleaser build --snapshot— compile the target matrix intodist/.goreleaser release --snapshot— full pipeline rehearsal (archives + checksums included), still fully offline.- Only after all four pass:
goreleaser releasewith a token — the publishing step.
check — exits 0/1/2, and what fail-open means here
- Exit codes measured:
0= valid;1= invalid (broken YAML syntax, unknown top-level key — the error names the Go struct:field <key> not found in type config.Project— or an unreadable file,open <file>: no such file or directory);2= valid but deprecated — a deprecated property (e.g. v1-stylearchives.format) printsDEPRECATED: archives.format should not be used anymorepluserror=configuration is valid, but uses deprecated propertiesand exits 2. -qis not a downgrade: quiet mode silences all output but the exit code is unchanged — a deprecated config still exits 2 with zero visible reason. Don't combine-qwithset -e-style CI scripts that only accept 0.version: 1configs pass with only a warning line (only version: 2 configuration files are supported, yours is version: 1). The version mismatch alone is warn-only; deprecated properties are what trips exit 2. A config with noversion:key at all is treated asversion: 0and fails rc 1.- Fail-open on a missing config: with no configuration file at all, check prints
could not find a configuration file, using defaults...and then validates the defaults. In a repo with a remote that defaults config passes rc 0 —checkexiting 0 never proves your.goreleaser.yamlwas seen. Point the command at the file explicitly when unsure. - Not just syntax — SCM context is enforced: check fails rc 1 outside a git repository
(
scm releases: current folder is not a git repository) and inside a repo without any remote (scm releases: no remote configured to list refs from). It reads the remote to derive the release target; a local filesystem remote satisfies it (see recipe 2).
build — snapshot versions, dist rules, filters
- Snapshot version strings (from the
building snapshot... version=line and the archive names): tagged repo with remote →0.1.0-SNAPSHOT-<shortsha>(tag minusv); untagged with remote →0.0.0-SNAPSHOT-<shortsha>; untagged with no git remote →0.0.0-SNAPSHOT-none— goreleaser skips git info when it cannot read a remote URL (couldn't get remote URL, thenignoring errors because this is a snapshot), so the sha suffix silently becomesnone. Keep a remote configured (a local bare repo counts) if snapshot names must be traceable. - Tagless build refuses:
goreleaser buildwithout--snapshotin a repo with no tags exits rc 1 with the remedy inline —git doesn't contain any tags - either add a tag or use --snapshot. dist/rerun wall: rerunning any non-clean build whendist/exists exits rc 1 (dist is not empty, remove it before running goreleaser or use the --clean flag). Pass--cleanwhenever a repeat run must succeed; onlybuildandreleasehave it.- Dirty tree rejects: uncommitted or untracked changes (untracked files count — an
uninitialized
dist/shows up as?? dist/unless gitignored) abort withgit is in a dirty stateplus the offending path list.--auto-snapshotdowngrades to a snapshot run whenever the tree is dirty instead of failing. --idfails open:goreleaser build --id bogusmatches no build, prints no error, and silently builds every target and exits 0. A typo'd id empties your selection without any signal — verify the built target list indist/.--single-target(build-only;releaserejects the flag withunknown flag: --single-target) builds the current platform only, and-o/--outputcopies that one binary to an exact path — verified as a real stripped ELF — but only with a single build id and--single-target.--skipon build acceptsbefore,post-hooks,pre-hooks,validate; an unknown value exits with the full valid list (--skip=befo is not allowed. Valid options for skip are [before, post-hooks, pre-hooks, validate]).- Target directories carry Go feature levels:
dist/hello_linux_amd64_v1/,dist/hello_linux_arm64_v8.0/(build idshellofrom the examples) — globhello_linux_amd64*if your script cannot depend on the suffix.dist/also accumulatesartifacts.json,metadata.json(commit,date,previous_tag,project_name,runtime,tag,version) andconfig.yaml— the effective merged config, the cheapest way to debug templates: read it back instead of guessing.
release — offline rehearsal, then the token wall
release --snapshotruns the entire pipeline offline: it printsskipping announce, publish, and validate...(snapshot implies--skip=announce,publish,validate) and still executes the build, a default archive step even when your config defines noarchives:(tar.gzper target) and checksum generation —<project>_<version>_linux_amd64.tar.gzplus<project>_<version>_checksums.txtindist/. Extend the skip with e.g.--skip=archive; the accepted token list is printed on an invalid one (announce, archive, aur, aur-source, before, changelog, chocolatey, docker, flatpak, homebrew, iru, ko, makeself, mcp, nfpm, nix, notarize, publish, sbom, scoop, sign, snapcraft, srpm, validate, winget).- A real publish fails closed before anything else: no
GITHUB_TOKEN,GITLAB_TOKENorGITEA_TOKENin the environment exits rc 1 withmissing GITHUB_TOKEN, GITLAB_TOKEN and GITEA_TOKEN. Other publish-path flags:--draft,--release-notes,--release-notes-tmpl,--fail-fast,--timeout.
Naming — what ProjectName actually is
ProjectName prefixes archives and checksum files and is not the module or directory name:
- Any configured git remote wins — including local filesystem remotes. The remote URL is parsed
as an SCM URL:
/tmp/grl/remote.gitrenamed the archives toremote_*, anddist/config.yamlrecorded a fictionalgithubtarget withowner: tmp/grl,name: remote. Readdist/config.yamlafter any suspicious naming surprise. - With no remote the fallback is the
go.modmodule path tail: moduleexample.com/hello→hello; renaming the module changed the archive prefix accordingly. - The per-build
binary:field names the executable inside, independent of ProjectName. Thedisttarget directory is keyed by the build id instead (dist/<id>_<os>_<arch>/); with noid:field it defaults to the project name — a config carryingbinary: helloand noid:produceddist/upstream_linux_amd64_v1/hello(projectupstream, binaryhello). Script against the id, not the binary field.
Recipes
Recipe 1 — install and verify, dodging the sbom-substring trap:
cd "$(mktemp -d)"
curl -sLO https://github.com/goreleaser/goreleaser/releases/latest/download/goreleaser_Linux_x86_64.tar.gz
curl -sLO https://github.com/goreleaser/goreleaser/releases/latest/download/checksums.txt
# anchored single-line match: substring grepping also catches the .sbom.json sidecar line
line=$(grep -E '^[0-9a-f]{64} goreleaser_Linux_x86_64\.tar\.gz$' checksums.txt)
grep -c '^' <<<"$line" | grep -qx 1 || { echo 'checksum line not unique'; exit 1; }
echo "$line" | sha256sum -c -
tar xzf goreleaser_Linux_x86_64.tar.gz
mkdir -p "$HOME/.local/bin" && cp goreleaser "$HOME/.local/bin/"
./goreleaser --version | grep -q 'GitVersion:' || { echo 'binary did not report a version'; exit 1; }
./goreleaser healthcheck 2>&1 | grep -q 'git' || { echo 'healthcheck did not report git'; exit 1; }
echo "recipe1 ok - binary installed to $HOME/.local/bin/goreleaser (add to PATH if missing)"
Recipe 2 — the check exit-code matrix (0 valid / 1 invalid / 2 deprecated) in a scratch repo:
d=$(mktemp -d); c=$(mktemp -d); git init -q --bare "$c/upstream.git"
cd "$(mktemp -d)" && git init -q -b main && git remote add origin "$c/upstream.git"
git -c [email protected] -c user.name=t commit -q --allow-empty -m init
printf 'version: 2\nbuilds:\n - main: .\n binary: x\n goos: [linux]\n goarch: [amd64]\n' > ok.yaml
printf 'version: 2\nbroken: [{\n' > bad.yaml
printf 'version: 2\narchives:\n - format: zip\n' > dep.yaml
goreleaser check ok.yaml > /dev/null 2>&1; rc=$?
[ "$rc" -eq 0 ] || { echo "expected 0, got $rc"; exit 1; }
goreleaser check bad.yaml > /dev/null 2>&1; rc=$?
[ "$rc" -eq 1 ] || { echo "expected 1, got $rc"; exit 1; }
goreleaser check dep.yaml > /dev/null 2>&1; rc=$?
[ "$rc" -eq 2 ] || { echo "expected 2 (deprecated), got $rc"; exit 1; }
goreleaser check dep.yaml -q; rc=$?
[ "$rc" -eq 2 ] || { echo "quiet mode must keep rc 2, got $rc"; exit 1; }
echo "recipe2 ok"
Recipe 3 — the snapshot loop: tagless refusal, snapshot build, offline release rehearsal:
go_on_path=1; command -v go >/dev/null || go_on_path=0
if [ "$go_on_path" -ne 1 ]; then echo 'go not on PATH - skipping'; exit 0; fi
d=$(mktemp -d); r=$(mktemp -d); git init -q --bare "$r/upstream.git"
cd "$d" && git init -q -b main && git remote add origin "$r/upstream.git"
go mod init example.com/hello >/dev/null
printf 'package main\nimport "fmt"\nfunc main() { fmt.Println("hi") }\n' > main.go
printf 'version: 2\nbuilds:\n - id: hello\n main: .\n binary: hello\n env: [CGO_ENABLED=0]\n goos: [linux]\n goarch: [amd64]\n' > .goreleaser.yaml
git add -A && git -c [email protected] -c user.name=t commit -qm init
goreleaser build > out.txt 2>&1; rc=$?
[ "$rc" -eq 1 ] && grep -q 'either add a tag or use --snapshot' out.txt || { echo 'tagless build should refuse with remedy'; exit 1; }
git tag v0.1.0
goreleaser release --snapshot --clean > rel.txt 2>&1; rc=$?
[ "$rc" -eq 0 ] || { cat rel.txt; exit 1; }
grep -q 'skipping announce, publish, and validate' rel.txt || { echo 'snapshot must skip announce+publish+validate'; exit 1; }
[ -f dist/hello_linux_amd64_v1/hello ] || { echo 'binary missing'; exit 1; }
ls dist/upstream_*_linux_amd64.tar.gz >/dev/null || { echo 'archive prefix should come from the remote repo name upstream'; exit 1; }
ls dist/upstream_*_checksums.txt >/dev/null || { echo 'checksums.txt missing'; exit 1; }
goreleaser build --snapshot > re.txt 2>&1; rc=$?
[ "$rc" -eq 1 ] && grep -q 'dist is not empty' re.txt || { echo 'rebuild into non-empty dist should refuse'; exit 1; }
goreleaser build --snapshot --clean >/dev/null 2>&1; [ $? -eq 0 ] || { echo 'clean rebuild must pass'; exit 1; }
echo "recipe3 ok"
Recipe 4 — ProjectName derivation: remote name wins, module tail is the no-remote fallback:
command -v go >/dev/null || { echo 'go not on PATH - skipping'; exit 0; }
d=$(mktemp -d); r=$(mktemp -d); git init -q --bare "$r/projA.git"
cd "$d" && git init -q -b main && git remote add origin "$r/projA.git"
go mod init example.com/projB >/dev/null
printf 'package main\nimport "fmt"\nfunc main() { fmt.Println("hi") }\n' > main.go
printf 'version: 2\nbuilds:\n - main: .\n binary: b\n env: [CGO_ENABLED=0]\n goos: [linux]\n goarch: [amd64]\n' > .goreleaser.yaml
git add -A && git -c [email protected] -c user.name=t commit -qm init
goreleaser release --snapshot --clean >/dev/null 2>&1; rc=$?
[ "$rc" -eq 0 ] || { echo 'snapshot release failed'; exit 1; }
ls dist/projA_*.tar.gz >/dev/null || { echo 'remote repo name should prefix archives'; exit 1; }
grep -q 'name: projA' dist/config.yaml || { echo 'local remote should set the github target name projA'; exit 1; }
grep -q 'owner:' dist/config.yaml || { echo 'local remote path should parse as an owner in the github target'; exit 1; }
git remote remove origin
goreleaser release --snapshot --clean >/dev/null 2>&1; rc=$?
[ "$rc" -eq 0 ] || { echo 'remote-less snapshot release failed'; exit 1; }
ls dist/projB_*.tar.gz >/dev/null || { echo 'module tail should prefix archives without a remote'; exit 1; }
echo "recipe4 ok"
Recipe 5 — traps: --id fail-open and the token wall:
command -v go >/dev/null || { echo 'go not on PATH - skipping'; exit 0; }
d=$(mktemp -d); r=$(mktemp -d); git init -q --bare "$r/upstream.git"
cd "$d" && git init -q -b main && git remote add origin "$r/upstream.git"
go mod init example.com/hello >/dev/null
printf 'package main\nimport "fmt"\nfunc main() { fmt.Println("hi") }\n' > main.go
printf 'version: 2\nbuilds:\n - main: .\n binary: hello\n env: [CGO_ENABLED=0]\n goos: [linux]\n goarch: [amd64, arm64]\n' > .goreleaser.yaml
git add -A && git -c [email protected] -c user.name=t commit -qm init && git tag v0.1.0
goreleaser build --snapshot --clean --id bogus >/dev/null 2>&1; rc=$?
[ "$rc" -eq 0 ] || { echo 'unknown id should silently succeed'; exit 1; }
n=$(find dist -mindepth 1 -maxdepth 1 -type d | wc -l)
[ "$n" -eq 2 ] || { echo "unknown id should still build ALL targets, built $n"; exit 1; }
goreleaser release > tok.txt 2>&1; rc=$?
[ "$rc" -eq 1 ] && grep -q 'missing GITHUB_TOKEN, GITLAB_TOKEN and GITEA_TOKEN' tok.txt || { echo 'publish without a token should fail closed with the token wall'; exit 1; }
echo "recipe5 ok"
Related skills
git-cliff— conventional-commit changelogs to feed--release-notes-tmpl.actionlint— validate the CI workflow file that invokes goreleaser.