Skip to content

Commit 972deec

Browse files
authored
Setup goreleaser to generate Go binaries. (#331)
* Setup goreleaser to generate Go binaries. Signed-off-by: Caleb Brown <[email protected]> * Use SLSA L3 instead of just cosign. Signed-off-by: Caleb Brown <[email protected]> --------- Signed-off-by: Caleb Brown <[email protected]>
1 parent 730ffd9 commit 972deec

File tree

4 files changed

+118
-6
lines changed

4 files changed

+118
-6
lines changed

.github/workflows/binary-release.yml

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

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ __pycache__/
1616

1717
# Test output
1818
unit-coverage.out
19+
20+
dist/

.goreleaser.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
project_name: criticality_score
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
7+
builds:
8+
- main: ./cmd/criticality_score
9+
id: "criticality_score"
10+
binary: criticality_score
11+
flags:
12+
- -buildvcs
13+
env:
14+
- CGO_ENABLED=0
15+
16+
- main: ./cmd/enumerate_github
17+
id: "enumerate_github"
18+
binary: enumerate_github
19+
env:
20+
- CGO_ENABLED=0
21+
22+
- main: ./cmd/scorer
23+
id: "scorer"
24+
binary: scorer
25+
env:
26+
- CGO_ENABLED=0
27+
28+
archives:
29+
- id: tarballs
30+
format: tar.gz
31+
format_overrides:
32+
- goos: windows
33+
format: zip
34+
files:
35+
- LICENSE
36+
- README.md
37+
- src: cmd/criticality_score/README.md
38+
dst: README_criticality_score.md
39+
- src: cmd/enumerate_github/README.md
40+
dst: README_enumerate_github.md
41+
- src: cmd/scorer/README.md
42+
dst: README_scorer.md
43+
rlcp: true
44+
45+
checksum:
46+
name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt'
47+
48+
snapshot:
49+
name_template: "{{ incpatch .Version }}-next"
50+
51+
changelog:
52+
skip: true
53+
54+
release:
55+
draft: false
56+
57+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
58+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

go.sum

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,6 @@ golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su
659659
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
660660
golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
661661
golang.org/x/net v0.0.0-20220401154927-543a649e0bdd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
662-
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
663-
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
664662
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
665663
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
666664
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@@ -769,8 +767,6 @@ golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBc
769767
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
770768
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
771769
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
772-
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
773-
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
774770
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
775771
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
776772
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
@@ -785,8 +781,6 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
785781
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
786782
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
787783
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
788-
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
789-
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
790784
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
791785
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
792786
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

0 commit comments

Comments
 (0)