Publish a GoReleaser release
Use this guide when GoReleaser builds your
archives and creates your GitHub release. At the end, each release also
carries a signed packslip.sigstore.json that describes those archives.
To sign from your own Go release tool instead, see Publish from Go.
Add the step after GoReleaser
GoReleaser does not write a release bundle, so the packslip action runs
as the next step of the same job and reads the archives GoReleaser left
in dist:
name: release
on:
push:
tags: ["v*"]
permissions:
contents: write # Create the release and upload the bundle.
id-token: write # Sign with the workflow's identity.
attestations: write # Attest the archives.
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version-file: go.mod
- uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7.3.0
with:
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ github.token }}
- uses: jdx/packslip@v1
with:
artifacts: dist/*.tar.gz dist/*.zip
bin: mytool
artifactslists only the archives.distalso holds GoReleaser's checksums,config.yaml,metadata.json, andartifacts.json, which are not artifacts. Add a glob for each other archive format you build.binnames the command. The step findsmytoolin each archive, ormytool.exein a Windows zip, and records its path.
On a tag push, the action derives the project, version, download URLs, and source commit from the repository and tag. Publish with GitHub Actions covers the other inputs, and Check the published result shows how to verify the release afterwards.
If the repository uses immutable releases, set release.draft: true in
.goreleaser.yaml and publish the release after this step, as
Prepare the files and release
explains.
Check what the step reads
packslip create reads each archive's OS, architecture, and format from
its name. It reads GoReleaser's default archive names and the names
goreleaser init writes:
| Archive | os | arch | format | bin |
|---|---|---|---|---|
mytool_1.2.3_linux_amd64.tar.gz | linux | x86_64 | tar.gz | mytool |
mytool_1.2.3_linux_arm64.tar.gz | linux | aarch64 | tar.gz | mytool |
mytool_1.2.3_linux_armv7.tar.gz | linux | armv7 | tar.gz | mytool |
mytool_1.2.3_linux_386.tar.gz | linux | i686 | tar.gz | mytool |
mytool_1.2.3_darwin_all.tar.gz | darwin | none | tar.gz | mytool |
mytool_1.2.3_windows_amd64.zip | windows | x86_64 | zip | mytool.exe |
mytool_Linux_x86_64.tar.gz | linux | x86_64 | tar.gz | mytool |
mytool_Darwin_arm64.tar.gz | darwin | aarch64 | tar.gz | mytool |
mytool_Windows_i386.zip | windows | i686 | zip | mytool.exe |
The universal macOS archive, darwin_all, records no arch, so every
Mac can select it. A build with CGO_ENABLED=0 is statically linked:
create records no libc, and the archive fits glibc and musl hosts.
For a cgo build, create reads the C library from the executable, as
C library explains.
If you changed name_template, check your own names before the first
release. Build without publishing, then create a trial bundle with a
local key:
goreleaser release --snapshot --clean
packslip keygen --out release.key
packslip create --key release.key --no-log \
--project mytool.example.com --version 1.2.3 --bin mytool \
--url-base https://mytool.example.com/v1.2.3 \
--out packslip dist/*.tar.gz dist/*.zip
packslip show packslip/packslip.sigstore.json
--snapshotbuilds the archives without a tag and publishes nothing.- The last arguments are the archives. Remove the glob for a format you
do not build, such as
dist/*.zipwithout a Windows build. Most shells pass an unmatched glob on as a file name, andcreatestops withNo such file or directory. - The
packslipflags are those of Several platforms, from release to verification, which explains each one. The trial bundle is not a release people can install.
For a name create reads wrongly, set the platform in a release.toml you
pass as manifest, as
Override the inferred platform
shows.
Give each CPU-level build a variant
A build matrix such as goamd64: [v1, v3] makes two archives for one
platform. Leave the default build without a variant and give the other
its CPU level. The variants input takes file names, and GoReleaser's
default names include the version, so read it from the tag first:
- name: Read the version from the tag
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"
- uses: jdx/packslip@v1
with:
artifacts: dist/*.tar.gz dist/*.zip
bin: mytool
variants: >-
mytool_${{ env.VERSION }}_linux_amd64v3.tar.gz=v3
mytool_${{ env.VERSION }}_windows_amd64v3.zip=v3
Consumers install the build without a variant unless the user asks for
one. Vocabularies in the specification lists
the CPU-level and softfloat variants, and
Separate builds that share a platform
gives the rules.
Troubleshoot
| Error | What to do |
|---|---|
artifact "artifacts.json": nothing in the name says what kind of file it is; give it a format, or leave it out of the artifacts if it is not one | artifacts matched GoReleaser's own files in dist. List only the archive globs, such as dist/*.tar.gz dist/*.zip. |
artifacts "mytool_1.2.3_linux_amd64.tar.gz" and "mytool_1.2.3_linux_amd64v3.tar.gz" both describe linux/x86_64/tar.gz; give one a variant so consumers can tell them apart | Give each CPU-level build a variant. |
no artifacts matched: artifacts=[…] download=[…] | The globs match nothing in dist. Check the archive formats in .goreleaser.yaml, and that this step runs in the job that ran GoReleaser. |
Troubleshoot publication lists the action's other errors.