-
Notifications
You must be signed in to change notification settings - Fork 1
175 lines (170 loc) · 5.37 KB
/
releaser.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Release
on:
workflow_dispatch:
inputs:
release:
description: 'Release version'
required: true
permissions: # added using https://github.com/step-security/secure-repo
contents: read
jobs:
release:
runs-on: macos-latest
permissions:
packages: read
contents: write
actions: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
with:
egress-policy: audit
-
name: Cancel previous workflows
uses: styfle/cancel-workflow-action@01ce38bf961b4e243a6342cbade0dbc8ba3f0432 # 0.12.0
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
-
name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.21'
check-latest: true
-
name: Cache Go modules
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
-
name: Download cyclonedx-gomod
uses: Zenithar/gh-gomod-generate-sbom@2cdc82f8e362b12fdec116b716ce0130baec8be2 # v1.0.3
with:
version: v1.2.0
github-token: ${{ secrets.GITHUB_TOKEN }}
-
name: Install Cosign
uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # v3.1.2
-
name: Import Code-Signing Certificates
uses: Apple-Actions/import-codesign-certs@8f3fb608891dd2244cdab3d69cd68c0d37a7fe93 # v2
with:
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
-
name: Install gon via HomeBrew for code signing and app notarization
run: |
brew tap mitchellh/gon
brew install mitchellh/gon/gon
brew install coreutils
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
with:
version: latest
args: release --clean --skip-publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Prepare Github release packages
run: |
#!/bin/bash
shopt -s expand_aliases
mkdir .dist
cp dist/harp-* .dist/
-
name: Sign and notarize MacOS CLIs
env:
AC_USERNAME: "${{ secrets.AC_USERNAME }}"
AC_PASSWORD: "${{ secrets.AC_PASSWORD }}"
run: |
echo '{
"source": [
"./dist/harp-darwin-amd64",
"./dist/harp-darwin-arm64"
],
"bundle_id":"io.harpsec.cli",
"apple_id": {},
"sign": { "application_identity": "AA99310C5F2AE5E79F93A92993930904F95B59FC" },
"zip": {
"output_path": "./dist/harp-darwin.zip"
}
}' | jq '' > gon.json
gon -log-level=debug -log-json ./gon.json
rm -f .dist/harp-darwin-amd64 .dist/harp-darwin-arm64
-
name: Prepare archives
run: |
#!/bin/bash
shopt -s expand_aliases
cd .dist/
unzip ../dist/harp-darwin.zip
FILES="*"
for f in $FILES;
do
case $f in
*.sbom.json)
continue
;;
harp-*)
fn=$(basename -s ".exe" $f)
tar czf ${fn}.tar.gz $f ${fn}.sbom.json
rm -f $f ${fn}.sbom.json
;;
esac
done
-
name: Sign
shell: bash
run: |
#!/bin/bash
shopt -s expand_aliases
cd .dist
sha256sum * > checksums.txt
FILES="*"
for f in $FILES;
do
case $f in
provenance.json|checksums.txt)
cosign sign-blob --key <(echo -n "${COSIGN_KEY}") "$f" > "$f.sig"
;;
*.tar.gz)
sha256sum "$f" | cut -d " " -f 1 > "$f.sha256"
cosign sign-blob --key <(echo -n "${COSIGN_KEY}") "$f" > "$f.sig"
;;
esac
done
env:
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
-
name: Verify
shell: bash
run: |
#!/bin/bash
shopt -s expand_aliases
curl -sLO https://raw.githubusercontent.com/zntrio/harp/v${{ github.event.inputs.release }}/build/artifact/cosign.pub
cd .dist
FILES="*"
for f in $FILES;
do
if [[ -f "$f.sig" ]];
then
cosign verify-blob --key ../cosign.pub --signature "$f.sig" $f
fi
done
-
name: Upload to release
uses: AButler/upload-release-assets@ec6d3263266dc57eb6645b5f75e827987f7c217d # v2.0
with:
files: '.dist/*'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: v${{ github.event.inputs.release }}