Skip to content

Commit 0647ea1

Browse files
authored
ci: build release binaries with goreleaser (#55)
* ci: build release binaries with goreleaser Six targets, matching the cross-compile job: linux, darwin and windows on amd64 and arm64. CGO_ENABLED=0 costs nothing — go-keyring shells out to `security` on macOS and talks D-Bus on Linux, neither of which needs cgo. The tag drives everything: release-please creates it and the release, then `mode: append` uploads the archives into that release without touching the notes it wrote. beep boop * ci: attest release archives goreleaser has no attestation of its own — the documented route is actions/attest after it runs. subject-checksums attests every file listed in checksums.txt, so all six archives are covered without naming them. Verify with `gh attestation verify --owner Flagsmith <file>`. beep boop * ci: mark beta releases as Latest GitHub will not let a prerelease be Latest ("Drafts and prereleases cannot be set as latest"), and the prerelease flag is not separable from the -beta version: release-please derives it from the version itself. So clear the flag after publishing instead. The condition takes itself out of service once 2.0.0 ships, since a stable release becomes Latest on its own. beep boop * ci: never touch the notes release-please wrote `mode` governs the release notes, not the artifacts — those upload either way. append happens to be harmless while the changelog is disabled, since our notes are empty, but keep-existing says what we mean and stays correct if anyone enables the changelog later. beep boop * fix: stop snapshot builds claiming to be a release .Tag is the last release tag even under --snapshot, so every snapshot stamped v1.1.0 and IsRelease then pinned doc URLs to a tag the build has nothing to do with. Snapshots now stamp the snapshot version, v1.1.0-SNAPSHOT-090323e. Stamping the literal `dev` would not have worked: resolve() treats dev as unstamped and replaces it from debug.ReadBuildInfo, which yields a Go pseudo-version — correct, but it would show up in --version and the User-Agent as v1.1.1-0.20260730115333-090323eb8be5+dirty. beep boop
1 parent c617925 commit 0647ea1

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
goreleaser:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write # upload release artifacts
15+
id-token: write # attest artifacts
16+
attestations: write
17+
steps:
18+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
19+
with:
20+
fetch-depth: 0
21+
persist-credentials: false
22+
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
23+
with:
24+
go-version-file: go.mod
25+
- uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
26+
with:
27+
version: "~> v2"
28+
args: release --clean
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
# Attests every file listed in the checksum file.
32+
- uses: actions/attest@508db95dd578ae2727ebd6217d5ba78e4fbda05d # v4.2.1
33+
with:
34+
subject-checksums: ./dist/checksums.txt
35+
36+
# During public beta the newest beta is what people
37+
# should land on, so clear it.
38+
- if: contains(github.ref_name, '-beta')
39+
run: gh release edit "$GITHUB_REF_NAME" --prerelease=false --latest
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
version: 2
2+
3+
builds:
4+
- binary: flagsmith
5+
env:
6+
- CGO_ENABLED=0
7+
flags:
8+
- -trimpath
9+
ldflags:
10+
- >-
11+
-s -w -X github.com/Flagsmith/flagsmith-cli/internal/version.Version={{ if .IsSnapshot }}v{{ .Version }}{{ else }}{{ .Tag }}{{ end }}
12+
mod_timestamp: "{{ .CommitTimestamp }}"
13+
goos:
14+
- linux
15+
- darwin
16+
- windows
17+
goarch:
18+
- amd64
19+
- arm64
20+
21+
archives:
22+
- name_template: "flagsmith_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
23+
formats:
24+
- tar.gz
25+
format_overrides:
26+
- goos: windows
27+
formats:
28+
- zip
29+
files:
30+
- LICENSE
31+
- README.md
32+
33+
checksum:
34+
name_template: checksums.txt
35+
36+
# changelog handled by release-please.
37+
changelog:
38+
disable: true
39+
40+
release:
41+
mode: keep-existing
42+
prerelease: auto

0 commit comments

Comments
 (0)