-
Notifications
You must be signed in to change notification settings - Fork 18
191 lines (188 loc) · 5.68 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Release
on:
workflow_dispatch:
inputs:
release:
description: 'Release version'
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
release:
runs-on: macos-latest
permissions:
packages: read
contents: write
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.19'
check-latest: true
-
name: Cache Go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
-
name: Download cyclonedx-gomod
uses: Zenithar/[email protected]
with:
version: v1.2.0
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
-
name: Install Cosign
uses: sigstore/[email protected]
-
name: Import Code-Signing Certificates
uses: Apple-Actions/import-codesign-certs@v1
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@v3
with:
version: latest
args: release --rm-dist --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 AMD64 cli
env:
AC_USERNAME: "${{ secrets.AC_USERNAME }}"
AC_PASSWORD: "${{ secrets.AC_PASSWORD }}"
run: |
echo '{
"source": ["./dist/harp-darwin-amd64"],
"bundle_id":"co.elastic.harp",
"apple_id": {},
"sign": { "application_identity": "9470D0A7B70090A8EF31C3B33AB3868B38B27A3D" },
"zip": {
"output_path": "./dist/harp-darwin-amd64.zip"
}
}' | jq '' > gon.amd64.json
gon -log-level=debug -log-json ./gon.amd64.json
rm -f .dist/harp-darwin-amd64
-
name: Sign and notarize MacOS ARM64 cli
env:
AC_USERNAME: "${{ secrets.AC_USERNAME }}"
AC_PASSWORD: "${{ secrets.AC_PASSWORD }}"
run: |
echo '{
"source": ["./dist/harp-darwin-arm64"],
"bundle_id":"co.elastic.harp",
"apple_id": {},
"sign": { "application_identity": "9470D0A7B70090A8EF31C3B33AB3868B38B27A3D" },
"zip": {
"output_path": "./dist/harp-darwin-arm64.zip"
}
}' | jq '' > gon.arm64.json
gon -log-level=debug -log-json ./gon.arm64.json
rm -f .dist/harp-darwin-arm64
-
name: Prepare archives
run: |
#!/bin/bash
shopt -s expand_aliases
cd .dist/
unzip ../dist/harp-darwin-amd64.zip
unzip ../dist/harp-darwin-arm64.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
# Disable provenance
#
#-
# name: Generate provenance for Release
# uses: philips-labs/[email protected]
# with:
# command: generate
# subcommand: files
# arguments: --artifact-path .dist --output-path '.dist/provenance.json'
# env:
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
-
name: Sign
shell: bash
run: |
#!/bin/bash
shopt -s expand_aliases
cd .dist
sha256sum *.tar.gz > 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/elastic/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/[email protected]
with:
files: '.dist/*'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: v${{ github.event.inputs.release }}