Skip to content

Commit 4057e20

Browse files
authored
Attempt at go releaser (google#38)
* Attempt at go releaser * Remove comments
1 parent f3d3ef0 commit 4057e20

File tree

4 files changed

+95
-79
lines changed

4 files changed

+95
-79
lines changed

.github/workflows/goreleaser.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- "*" # triggers only if push new tag version, like `0.8.4` or else
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
goreleaser:
13+
outputs:
14+
hashes: ${{ steps.hash.outputs.hashes }}
15+
permissions:
16+
contents: write # for goreleaser/goreleaser-action to create a GitHub release
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v2.3.4
21+
with:
22+
fetch-depth: 0
23+
- name: Set up Go
24+
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v2.2.0
25+
with:
26+
go-version: 1.19
27+
check-latest: true
28+
- name: Run GoReleaser
29+
id: run-goreleaser
30+
uses: goreleaser/goreleaser-action@b508e2e3ef3b19d4e4146d4f8fb3ba9db644a757 # v2.5.0
31+
with:
32+
version: latest
33+
args: release --rm-dist
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
- name: Generate subject
37+
id: hash
38+
env:
39+
ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}"
40+
run: |
41+
set -euo pipefail
42+
checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path')
43+
echo "hashes=$(cat $checksum_file | base64 -w0)" >> "$GITHUB_OUTPUT"
44+
provenance:
45+
needs: [goreleaser]
46+
permissions:
47+
actions: read # To read the workflow path.
48+
id-token: write # To sign the provenance.
49+
contents: write # To add assets to a release.
50+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.4.0
51+
with:
52+
base64-subjects: "${{ needs.goreleaser.outputs.hashes }}"
53+
upload-assets: true # upload to a new release

.github/workflows/slsa-goreleaser.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.goreleaser.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
before:
2+
hooks:
3+
- go mod tidy
4+
builds:
5+
- env:
6+
# goreleaser does not work with CGO, it could also complicate
7+
# usage by users in CI/CD systems like Terraform Cloud where
8+
# they are unable to install libraries.
9+
- CGO_ENABLED=0
10+
- GO111MODULE=on
11+
mod_timestamp: '{{ .CommitTimestamp }}'
12+
flags:
13+
- -trimpath
14+
ldflags:
15+
# prettier-ignore
16+
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.CommitDate}}'
17+
goos:
18+
# Further testing before supporting freebsd
19+
# - freebsd
20+
- windows
21+
- linux
22+
- darwin
23+
goarch:
24+
- amd64
25+
- '386'
26+
# Further testing before supporting arm
27+
# - arm
28+
# - arm64
29+
ignore:
30+
- goos: linux
31+
goarch: amd64
32+
binary: '{{ .ProjectName }}_v{{ .Version }}'
33+
archives:
34+
- format: binary
35+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
36+
checksum:
37+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
38+
algorithm: sha256
39+
release:
40+
draft: true
41+
changelog:
42+
skip: true

.slsa-goreleaser.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)