goreleaser

Set up and drive goreleaser v2 release automation — generate a starter config, validate it with check (exit codes 0/1/2, where 2 = valid but deprecated), build artifacts offline with build --snapshot, rehearse a whole release with release --snapshot before ever publishing, wire the CI token step, or debug unexpected exit codes from check, build or release. Covers snapshot version strings, dist rerun and dirty-tree refusals, --id and ProjectName naming traps. Measured on goreleaser v2.20.3.

Qu'est-ce que goreleaser ?

goreleaser is a Claude Code agent skill that set up and drive goreleaser v2 release automation — generate a starter config, validate it with check (exit codes 0/1/2, where 2 = valid but deprecated), build artifacts offline with build --snapshot, rehearse a whole release with release --snapshot before ever publishing, wire the CI token step, or debug unexpected exit codes from check, build or release. Covers snapshot version strings, dist rerun and dirty-tree refusals, --id and ProjectName naming traps. Measured on goreleaser v2.20.3.

Compatible avec~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/H190K/agent-skills-hub/tree/HEAD/skills/goreleaser

Installed? Explore more Développement et programmation skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

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, plus checksums.txt and a Sigstore attestation checksums.txt.sigstore.json). Extracted payload: one goreleaser binary, LICENSE.md, README.md, manpages/, completions/.
  • Checksum-trap: checksums.txt lists the SBOM sidecar files too (goreleaser_Linux_x86_64.tar.gz.sbom.json). A bare grep 'goreleaser_Linux_x86_64.tar.gz' checksums.txt matches two lines (the tarball and its sidecar, whose name contains the tarball name as a substring) and sha256sum -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 build are git and a Go toolchain (goreleaser healthcheck prints ✓ git / ✓ go and 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

  1. goreleaser init — scaffold .goreleaser.yaml + dist/ into .gitignore (see traps).
  2. goreleaser check — validate config. Requires a git repo with a configured remote.
  3. goreleaser build --snapshot — compile the target matrix into dist/.
  4. goreleaser release --snapshot — full pipeline rehearsal (archives + checksums included), still fully offline.
  5. Only after all four pass: goreleaser release with 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-style archives.format) prints DEPRECATED: archives.format should not be used anymore plus error=configuration is valid, but uses deprecated properties and exits 2.
  • -q is 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 -q with set -e-style CI scripts that only accept 0.
  • version: 1 configs 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 no version: key at all is treated as version: 0 and 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 — check exiting 0 never proves your .goreleaser.yaml was 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 minus v); 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, then ignoring errors because this is a snapshot), so the sha suffix silently becomes none. Keep a remote configured (a local bare repo counts) if snapshot names must be traceable.
  • Tagless build refuses: goreleaser build without --snapshot in 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 when dist/ exists exits rc 1 (dist is not empty, remove it before running goreleaser or use the --clean flag). Pass --clean whenever a repeat run must succeed; only build and release have it.
  • Dirty tree rejects: uncommitted or untracked changes (untracked files count — an uninitialized dist/ shows up as ?? dist/ unless gitignored) abort with git is in a dirty state plus the offending path list. --auto-snapshot downgrades to a snapshot run whenever the tree is dirty instead of failing.
  • --id fails open: goreleaser build --id bogus matches 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 in dist/.
  • --single-target (build-only; release rejects the flag with unknown flag: --single-target) builds the current platform only, and -o/--output copies that one binary to an exact path — verified as a real stripped ELF — but only with a single build id and --single-target.
  • --skip on build accepts before, 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 ids hello from the examples) — glob hello_linux_amd64* if your script cannot depend on the suffix. dist/ also accumulates artifacts.json, metadata.json (commit, date, previous_tag, project_name, runtime, tag, version) and config.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 --snapshot runs the entire pipeline offline: it prints skipping announce, publish, and validate... (snapshot implies --skip=announce,publish,validate) and still executes the build, a default archive step even when your config defines no archives: (tar.gz per target) and checksum generation — <project>_<version>_linux_amd64.tar.gz plus <project>_<version>_checksums.txt in dist/. 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_TOKEN or GITEA_TOKEN in the environment exits rc 1 with missing 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.git renamed the archives to remote_*, and dist/config.yaml recorded a fictional github target with owner: tmp/grl, name: remote. Read dist/config.yaml after any suspicious naming surprise.
  • With no remote the fallback is the go.mod module path tail: module example.com/hello → hello; renaming the module changed the archive prefix accordingly.
  • The per-build binary: field names the executable inside, independent of ProjectName. The dist target directory is keyed by the build id instead (dist/<id>_<os>_<arch>/); with no id: field it defaults to the project name — a config carrying binary: hello and no id: produced dist/upstream_linux_amd64_v1/hello (project upstream, binary hello). 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.

Individual skills in this repo

This repo contains 1 individual skill — each has its own dedicated page.

Skills associés