@@ -2,54 +2,97 @@ name: release
22
33on :
44 push :
5- branches :
6- - master
7- - main
5+ branches : [main, master]
86
97jobs :
10-
11- tag :
12- runs-on : ubuntu-latest
13- steps :
14- -
15- uses : actions/checkout@v4
16- -
17- uses : go-semantic-release/action@v1
18- with :
19- github-token : ${{ secrets.GITHUB_TOKEN }}
20-
218 goreleaser :
229 runs-on : ubuntu-latest
23- needs : tag
10+
11+ outputs :
12+ hashes : ${{ steps.hashes.outputs.hashes }}
13+ version : ${{ steps.semrel.outputs.version }}
14+
15+ permissions :
16+ contents : write
17+ packages : write
18+
2419 steps :
2520 -
2621 name : Checkout
2722 uses : actions/checkout@v4
23+ with :
24+ fetch-depth : 0
2825 -
29- name : Unshallow
30- run : git fetch --prune --unshallow
31- -
32- id : versions
26+ id : vars
3327 run : |
34- echo ::set-output name=go::$(grep '^FROM go' .github/go/Dockerfile | cut -d ' ' -f 2 | cut -d ':' -f 2)
35- echo "Using Go version ${{ steps.versions.outputs.go }}"
28+ goVersion=$(grep '^FROM go' .github/go/Dockerfile | cut -d ' ' -f 2 | cut -d ':' -f 2)
29+ echo "go_version=${goVersion}" >> $GITHUB_OUTPUT
30+ echo "Using Go version ${goVersion}"
3631 -
3732 name : Set up Go
3833 uses : actions/setup-go@v5
3934 with :
40- go-version : ${{ steps.versions .outputs.go }}
35+ go-version : ${{ steps.vars .outputs.go_version }}
4136 -
42- name : Login to GitHub Container Registry
37+ name : Run Trivy in GitHub SBOM mode and submit results to Dependency Snapshots
38+ uses : aquasecurity/trivy-action@master
39+ with :
40+ scan-type : ' fs'
41+ format : ' github'
42+ output : ' dependency-results.sbom.json'
43+ image-ref : ' .'
44+ github-pat : ${{ secrets.GH_PRIVATEREPO_TOKEN }}
45+ -
46+ name : Remove SBOM result
47+ run : |
48+ rm dependency-results.sbom.json
49+ -
50+ name : Install syft
51+ run : |
52+ curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
53+ -
54+ name : Create release tag
55+ uses : go-semantic-release/action@v1
56+ id : semrel
57+ with :
58+ github-token : ${{ secrets.GITHUB_TOKEN }}
59+ -
60+ run : git fetch -a
61+ if : steps.semrel.outputs.version != ''
62+ -
63+ name : Login to GitHub Docker registry
64+ if : steps.semrel.outputs.version != ''
4365 uses : docker/login-action@v3
4466 with :
4567 registry : ghcr.io
4668 username : ${{ github.repository_owner }}
4769 password : ${{ secrets.GITHUB_TOKEN }}
4870 -
4971 name : Release
50- uses : goreleaser/goreleaser-action@v6
72+ uses :
goreleaser/[email protected] 73+ if : steps.semrel.outputs.version != ''
5174 with :
5275 version : latest
5376 args : release --config=.github/goreleaser.yml --clean
5477 env :
5578 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
79+ -
80+ name : Generate dist hashes
81+ id : hashes
82+ if : steps.semrel.outputs.version != ''
83+ env :
84+ ARTIFACTS : " ${{ steps.goreleaser.outputs.artifacts }}"
85+ run : |
86+ checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path')
87+ echo "hashes=$(cat $checksum_file | base64 -w0)" >> $GITHUB_OUTPUT
88+
89+ provenance :
90+ needs : [goreleaser]
91+ if : needs.goreleaser.outputs.hashes != ''
92+ permissions :
93+ actions : read # To read the workflow path.
94+ id-token : write # To sign the provenance.
95+ contents : write # To add assets to a release.
96+ uses :
slsa-framework/slsa-github-generator/.github/workflows/[email protected] 97+ with :
98+ base64-subjects : " ${{ needs.goreleaser.outputs.hashes }}"
0 commit comments