-
Notifications
You must be signed in to change notification settings - Fork 9
350 lines (349 loc) · 15.9 KB
/
create-prerelease.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
name: Build and Create Pre-Release
on:
workflow_dispatch:
inputs:
addCommit:
description: 'Dev build?'
required: false
type: boolean
deletePrevBuild:
description: 'Delete existing pre-releases?'
required: false
type: boolean
sendSlackMessage:
description: 'Send Slack Message?'
required: false
type: boolean
message:
description: "What changed (for slack message)"
required: true
jobs:
build-linux:
runs-on: ubuntu-22.04
steps:
- name: "Git checkout"
uses: actions/checkout@v3
- name: "Install Golang"
run: |
set -e
pushd /tmp
wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz
popd
export PATH=/usr/local/go/bin:$PATH
go version
- name: "Compile"
env:
ADDCOMMIT: ${{ inputs.addCommit }}
run: |
export PATH=/usr/local/go/bin:/usr/local/bin:$PATH
cd ~/work/aerolab/aerolab/src && make cleanall
if [ "${ADDCOMMIT}" = "false" ]; then make official compile_linux_wip_amd64 compile_linux_wip_arm64 reset1 compile_linux_amd64 compile_linux_arm64 reset2; fi
if [ "${ADDCOMMIT}" != "false" ]; then make prerelease compile_linux_wip_amd64 compile_linux_wip_arm64 reset1 compile_linux_amd64 compile_linux_arm64 reset2; fi
exit 0
- name: "Create linux packages"
env:
ADDCOMMIT: ${{ inputs.addCommit }}
run: |
export PATH=/usr/local/go/bin:/usr/local/bin:$PATH
cd ~/work/aerolab/aerolab/src && make pkg-linux
- name: setup GPG
uses: aerospike/shared-workflows/devops/setup-gpg@main
with:
gpg-private-key: ${{ secrets.GPG_SECRET_KEY_ORG }}
gpg-public-key: ${{ secrets.GPG_PUBLIC_KEY_ORG }}
gpg-key-pass: ${{ secrets.GPG_PASS_ORG }}
gpg-key-name: "Aerospike"
- name: "Sign linux packages"
env:
GPG_TTY: no-tty
GPG_PASSPHRASE: ${{ secrets.GPG_PASS_ORG }}
run: |
# GPG sign rpm packages
cd ~/work/aerolab/aerolab/bin/packages
ls *.rpm |while read file; do
echo "Signing ${file}..."
rpm --addsign "${file}"
OUTPUT=$(rpm --checksig "${file}")
if [[ "$OUTPUT" =~ 'digests signatures OK' ]]; then
echo "Successfully GPG Signing $file"
else
echo "$OUTPUT"
echo "GPG Signing $file has failed."
exit 1
fi
done
# GPG sign deb packages
sudo chmod 777 ../packages
ls *.deb |while read file; do
echo "Signing ${file}..."
sudo chmod 777 ${file}
dpkg-sig --sign builder "${file}"
OUTPUT=$(dpkg-sig --verify "${file}")
if [[ "$OUTPUT" =~ 'GOODSIG _gpgbuilder' ]]; then
echo "Successfully GPG Signing $file"
else
echo "$OUTPUT"
echo "GPG Signing $file has failed."
exit 1
fi
done
- name: "Export artifacts"
uses: actions/upload-artifact@v4
with:
name: linux
path: ~/work/aerolab/aerolab/bin/packages
build-windows:
runs-on: ubuntu-22.04
steps:
- name: "Git checkout"
uses: actions/checkout@v3
- name: "Install Golang"
run: |
set -e
pushd /tmp
wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz
popd
export PATH=/usr/local/go/bin:$PATH
go version
- name: "Compile"
env:
ADDCOMMIT: ${{ inputs.addCommit }}
run: |
export PATH=/usr/local/go/bin:/usr/local/bin:$PATH
cd ~/work/aerolab/aerolab/src && make cleanall
if [ "${ADDCOMMIT}" = "false" ]; then make official compile_linux_wip_amd64 compile_linux_wip_arm64 reset1 compile_windows reset2; fi
if [ "${ADDCOMMIT}" != "false" ]; then make prerelease compile_linux_wip_amd64 compile_linux_wip_arm64 reset1 compile_windows reset2; fi
exit 0
- name: "Create windows zips"
env:
ADDCOMMIT: ${{ inputs.addCommit }}
run: |
export PATH=/usr/local/go/bin:/usr/local/bin:$PATH
cd ~/work/aerolab/aerolab/src && make pkg-windows-zip
- name: "Export artifacts"
uses: actions/upload-artifact@v4
with:
name: windows
path: ~/work/aerolab/aerolab/bin/packages
build-macos:
runs-on: macos-13
steps:
- name: "Git checkout"
uses: actions/checkout@v3
- name: "Install golang"
run: |
wget https://go.dev/dl/go1.23.4.darwin-amd64.pkg
sudo installer -store -pkg go1.23.4.darwin-amd64.pkg -target /
- name: "Install Packages.pkg for making macos PKG files"
run: |
wget http://s.sudre.free.fr/Software/files/Packages.dmg
hdiutil attach -mountpoint /Volumes/Packages Packages.dmg
cd /Volumes/Packages
sudo installer -pkg Install\ Packages.pkg -target /
- name: "Compile"
env:
ADDCOMMIT: ${{ inputs.addCommit }}
run: |
export PATH=/usr/local/go/bin:/usr/local/bin:$PATH
cd ~/work/aerolab/aerolab/src && make cleanall
if [ "${ADDCOMMIT}" = "false" ]; then make official compile_linux_wip_amd64 compile_linux_wip_arm64 reset1 compile_darwin reset2; fi
if [ "${ADDCOMMIT}" != "false" ]; then make prerelease compile_linux_wip_amd64 compile_linux_wip_arm64 reset1 compile_darwin reset2; fi
exit 0
- name: "Prepare keychain for signing MacOS"
env:
keypw: ${{ secrets.APPLEPW }}
INSTALLERP12: ${{ secrets.INSTALLERP12 }}
APPLICATIONP12: ${{ secrets.APPLICATIONP12 }}
run: |
set -e
security create-keychain -p mysecretpassword build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p mysecretpassword build.keychain
security set-keychain-settings build.keychain
security unlock-keychain -p mysecretpassword build.keychain
echo "$APPLICATIONP12" | base64 -d > app.p12
echo "$INSTALLERP12" | base64 -d > install.p12
security import app.p12 -k build.keychain -P $keypw -A
security import install.p12 -k build.keychain -P $keypw -A
security set-key-partition-list -S apple-tool:,apple: -s -k mysecretpassword build.keychain
- name: "Sign, package and notarize MacOS"
env:
xaerolab_appleid: ${{ secrets.APPLEUSER }}
xaerolab_applepw: ${{ secrets.APPLEPW }}
xaerolab_signer: ${{ secrets.APPLESIGNER }}
xaerolab_installsigner: ${{ secrets.APPLEINSTALLSIGNER }}
xaerolab_teamid: ${{ secrets.APPLETEAMID }}
run: |
set -e
export aerolab_appleid="${xaerolab_appleid}"
export aerolab_applepw="${xaerolab_applepw}"
export aerolab_signer="${xaerolab_signer}"
export aerolab_installsigner="${xaerolab_installsigner}"
export aerolab_teamid="${xaerolab_teamid}"
export PATH=/usr/local/go/bin:/usr/local/bin:$PATH && cd ~/work/aerolab/aerolab/src && make macos-build-all && make macos-notarize-all
- name: "Export artifacts"
uses: actions/upload-artifact@v4
with:
name: darwin
path: ~/work/aerolab/aerolab/bin/packages
release:
needs: [build-macos, build-windows, build-linux]
runs-on: ubuntu-22.04
steps:
- name: "Git checkout"
uses: actions/checkout@v3
- name: "Download linux artifacts"
uses: actions/download-artifact@v4
with:
name: linux
path: Rlinux/
- name: "Download windows artifacts"
uses: actions/download-artifact@v4
with:
name: windows
path: Rwindows/
- name: "Download macos artifacts"
uses: actions/download-artifact@v4
with:
name: darwin
path: Rdarwin/
- name: "Generate sha256 signatures"
run: |
cd Rlinux
ls |while read f; do shasum -a 256 $f > $f.sha256; done
cd ../Rwindows
ls |while read f; do shasum -a 256 $f > $f.sha256; done
cd ../Rdarwin
ls |while read f; do shasum -a 256 $f > $f.sha256; done
cd ..
- name: setup GPG
uses: aerospike/shared-workflows/devops/setup-gpg@main
with:
gpg-private-key: ${{ secrets.GPG_SECRET_KEY_ORG }}
gpg-public-key: ${{ secrets.GPG_PUBLIC_KEY_ORG }}
gpg-key-pass: ${{ secrets.GPG_PASS_ORG }}
gpg-key-name: "Aerospike"
- name: "Generate asc signatures"
env:
GPG_TTY: no-tty
GPG_PASSPHRASE: ${{ secrets.GPG_PASS_ORG }}
run: |
cd Rlinux
ls |while read file; do
DO=0
echo "${file}" |egrep '(\.deb|\.rpm)$' &>/dev/null || DO=1
if [ $DO -ne 0 ]; then
echo "Generating asc for ${file}"
gpg --detach-sign --no-tty --batch --yes --output "${file}.asc" --passphrase "$GPG_PASSPHRASE" "${file}" || exit 1
gpg --verify "${file}.asc" "${file}" &>/dev/null || exit 1
fi
done
cd ../Rwindows
ls |while read file; do
echo "Generating asc for ${file}"
gpg --detach-sign --no-tty --batch --yes --output "${file}.asc" --passphrase "$GPG_PASSPHRASE" "${file}" || exit 1
gpg --verify "${file}.asc" "${file}" &>/dev/null || exit 1
done
cd ../Rdarwin
ls |while read file; do
echo "Generating asc for ${file}"
gpg --detach-sign --no-tty --batch --yes --output "${file}.asc" --passphrase "$GPG_PASSPHRASE" "${file}" || exit 1
gpg --verify "${file}.asc" "${file}" &>/dev/null || exit 1
done
cd ..
- name: "Create a new release"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ADDCOMMIT: ${{ inputs.addCommit }}
run: |
set -e
echo "${ADDCOMMIT}"
COMMIT=$(git rev-parse --short HEAD)
VER=$(cat VERSION.md)
BRANCH=$(git rev-parse --abbrev-ref HEAD)
TAG=${VER}-${COMMIT}
[ "${ADDCOMMIT}" = "false" ] && TAG=${VER}
FULLCOMMIT=$(git rev-parse HEAD)
PRE_PARAM="--prerelease"
[ "${ADDCOMMIT}" = "false" ] && PRE_PARAM="--latest"
echo "Linux artifacts:"
ls Rlinux/
echo "Windows artifacts:"
ls Rwindows/
echo "Darwin artifacts:"
ls Rdarwin/
gh release create -R github.com/aerospike/aerolab --notes-file RELEASE.md ${PRE_PARAM} --target ${FULLCOMMIT} --title "AeroLab - v${TAG}" ${TAG} Rlinux/* Rwindows/* Rdarwin/*
post-release:
needs: release
runs-on: ubuntu-22.04
steps:
- name: "Git checkout"
uses: actions/checkout@v3
- name: "Delete previous pre-release"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DELPREV: ${{ inputs.deletePrevBuild }}
ADDCOMMIT: ${{ inputs.addCommit }}
run: |
if [ "${DELPREV}" = "true" ]
then
set -e
cd ~/work/aerolab/aerolab
echo "${ADDCOMMIT}"
COMMIT=$(git rev-parse --short HEAD)
VER=$(cat VERSION.md)
TAG=${VER}-${COMMIT}
[ "${ADDCOMMIT}" = "false" ] && TAG=${VER}
echo "Protected tag: ${TAG}"
gh release list -R github.com/aerospike/aerolab -L 100 |grep Pre-release |awk -F'\t' '{print $3}' |while read line
do
if [ "$line" != "${TAG}" ]
then
if [[ $line =~ ^${VER}- ]]
then
echo "Removing $line"
gh release delete $line -R github.com/aerospike/aerolab --yes --cleanup-tag
fi
fi
done
fi
- name: "Trigger homebrew-tools workflow"
env:
PAT: ${{ secrets.PAT }}
ADDCOMMIT: ${{ inputs.addCommit }}
run: |
if [ "${ADDCOMMIT}" = "false" ]; then
version=$(cat VERSION.md)
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/aerospike/homebrew-tools/dispatches \
-d "{\"event_type\": \"aerolab\", \"client_payload\": {\"isLatest\": true, \"version\": \"$version\"}}"
fi
- name: "Send slack notification"
env:
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
ADDCOMMIT: ${{ inputs.addCommit }}
MESSAGE: ${{ inputs.message }}
SENDSLACK: ${{ inputs.sendSlackMessage }}
run: |
if [ "${SENDSLACK}" = "true" ]
then
echo "${ADDCOMMIT}"
cd ~/work/aerolab/aerolab
COMMIT=$(git rev-parse --short HEAD)
VER=$(cat VERSION.md)
if [ "${ADDCOMMIT}" = "true" ]
then
TAG=${VER}-${COMMIT}
curl -d "text=A new dev build is available at https://github.com/aerospike/aerolab/releases/tag/${TAG} Changes: ${MESSAGE}" -d "channel=${SLACK_CHANNEL}" -H "Authorization: Bearer ${SLACK_TOKEN}" -X POST https://slack.com/api/chat.postMessage || exit 0
else
TAG=${VER}
curl -d "text=A new release is available at https://github.com/aerospike/aerolab/releases/tag/${TAG} Changes: ${MESSAGE}" -d "channel=${SLACK_CHANNEL}" -H "Authorization: Bearer ${SLACK_TOKEN}" -X POST https://slack.com/api/chat.postMessage || exit 0
fi
fi