Skip to content

Commit e9bb7b8

Browse files
authored
Merge pull request #604 from stefanprodan/release-goreleaser-v2
ci(release): Migrate to GoReleaser v2 and attest release assets
2 parents 50960a0 + a01deca commit e9bb7b8

2 files changed

Lines changed: 53 additions & 43 deletions

File tree

.github/workflows/release.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,39 @@ jobs:
1414
version: ${{ steps.hash.outputs.version }}
1515
runs-on: ubuntu-latest
1616
permissions:
17+
artifact-metadata: write
18+
attestations: write
1719
contents: write
1820
id-token: write
1921
packages: write
2022
steps:
2123
- name: Checkout
2224
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
23-
- name: Unshallow
24-
run: git fetch --prune --unshallow
25+
with:
26+
fetch-depth: 0
2527
- name: Setup Go
2628
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
2729
with:
2830
go-version: 1.26.x
2931
cache: false
3032
- name: Setup Syft
3133
uses: anchore/sbom-action/download-syft@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
34+
- name: Version info
35+
id: ver
36+
run: |
37+
echo "SEMVER=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
3238
- name: Run GoReleaser
3339
id: run-goreleaser
3440
uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
3541
with:
3642
version: latest
37-
args: release --skip=validate
43+
args: release
3844
env:
3945
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_TOKEN }}
46+
- name: Attest release assets
47+
uses: actions/attest@508db95dd578ae2727ebd6217d5ba78e4fbda05d # v4.2.1
48+
with:
49+
subject-checksums: '${{ github.workspace }}/dist/${{ github.event.repository.name }}_${{ steps.ver.outputs.SEMVER }}_checksums.txt'
4150
- name: Generate SLSA subject
4251
id: hash
4352
env:

.goreleaser.yml

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,77 @@
1-
project_name: timoni
1+
version: 2
2+
3+
# xref: https://goreleaser.com/customization/hooks/
4+
before:
5+
hooks:
6+
- go mod download
7+
8+
# xref: https://goreleaser.com/customization/env/
9+
env:
10+
- CGO_ENABLED=0
11+
12+
# xref: https://goreleaser.com/customization/changelog/
213
changelog:
314
use: github-native
15+
16+
# xref: https://goreleaser.com/customization/build/
417
builds:
518
- <<: &build_defaults
6-
binary: timoni
7-
main: ./cmd/timoni
19+
main: ./cmd/{{ .ProjectName }}
820
ldflags:
921
- -s -w -X main.VERSION={{ .Version }}
10-
env:
11-
- CGO_ENABLED=0
12-
id: linux
22+
id: linux-build
1323
goos:
1424
- linux
1525
goarch:
1626
- amd64
1727
- arm64
1828
- <<: *build_defaults
19-
id: darwin
29+
id: darwin-build
2030
goos:
2131
- darwin
2232
goarch:
2333
- amd64
2434
- arm64
2535
- <<: *build_defaults
26-
id: windows
36+
id: windows-build
2737
goos:
2838
- windows
2939
goarch:
3040
- amd64
41+
- arm64
42+
43+
# xref: https://goreleaser.com/customization/archive/
3144
archives:
3245
- name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
33-
id: nix
34-
builds: [darwin, linux]
35-
format: tar.gz
46+
id: unix-cli
47+
ids:
48+
- darwin-build
49+
- linux-build
50+
formats:
51+
- tar.gz
3652
files:
3753
- LICENSE
3854
- name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
39-
id: windows
40-
builds: [windows]
41-
format: zip
55+
id: windows-cli
56+
ids:
57+
- windows-build
58+
formats:
59+
- zip
4260
files:
4361
- LICENSE
62+
63+
# xref: https://goreleaser.com/customization/checksum/
64+
checksum:
65+
algorithm: sha256
66+
67+
# xref: https://goreleaser.com/customization/source/
4468
source:
4569
enabled: true
4670
name_template: '{{ .ProjectName }}_{{ .Version }}_source_code'
71+
72+
# xref: https://goreleaser.com/customization/sbom/
4773
sboms:
4874
- id: source
4975
artifacts: source
5076
documents:
5177
- "{{ .ProjectName }}_{{ .Version }}_sbom.spdx.json"
52-
brews:
53-
- name: timoni
54-
repository:
55-
owner: stefanprodan
56-
name: homebrew-tap
57-
branch: main
58-
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
59-
directory: Formula
60-
homepage: "https://timoni.sh"
61-
description: "Timoni CLI"
62-
dependencies:
63-
- name: cue
64-
type: optional
65-
- name: diffutils
66-
type: optional
67-
install: |
68-
bin.install "timoni"
69-
bash_output = Utils.safe_popen_read(bin/"timoni", "completion", "bash")
70-
(bash_completion/"timoni").write bash_output
71-
zsh_output = Utils.safe_popen_read(bin/"timoni", "completion", "zsh")
72-
(zsh_completion/"_timoni").write zsh_output
73-
fish_output = Utils.safe_popen_read(bin/"timoni", "completion", "fish")
74-
(fish_completion/"timoni.fish").write fish_output
75-
test: |
76-
system "#{bin}/timoni version"

0 commit comments

Comments
 (0)