-
-
Notifications
You must be signed in to change notification settings - Fork 146
460 lines (411 loc) · 16.8 KB
/
desktop-app-cd-prod.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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
name: Leapp Desktop App CD - prod
on:
push:
branches:
- master
env:
CERTIFICATE_APPLICATION_OSX_P12: ${{ secrets.CERTIFICATE_APPLICATION_OSX_P12 }}
CERTIFICATE_OSX_P12: ${{ secrets.CERTIFICATE_OSX_P12 }}
DECODE_PASSWORD: ${{ secrets.DECODE_PASSWORD }}
DISTRIBUTION_ID: ${{ secrets.DISTRIBUTION_ID }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
S3_BUCKET: s3://noovolari-leapp-website-distribution
WIN_CERTIFICATE: ${{ secrets.WIN_CERTIFICATE }}
WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CSC_KEY_PASSWORD }}
ESIGNER_WIN_USERNAME: ${{ secrets.ESIGNER_WIN_USERNAME }}
ESIGNER_WIN_PASSWORD: ${{ secrets.ESIGNER_WIN_PASSWORD }}
ESIGNER_WIN_CREDENTIAL_ID: ${{ secrets.ESIGNER_WIN_CREDENTIAL_ID }}
ESIGNER_WIN_TOTP: ${{ secrets.ESIGNER_WIN_TOTP }}
ESIGNER_WIN_CLIENT_ID: ${{ secrets.ESIGNER_WIN_CLIENT_ID }}
TEAM_REPOSITORY: ${{ secrets.TEAM_REPOSITORY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
jobs:
tag-validation:
outputs:
validator: ${{ steps.validator.outputs.VALID_TAG }}
tag-version: ${{ steps.validator.outputs.TAG_VERSION }}
tag-version-without-v: ${{ steps.validator.outputs.TAG_VERSION_WITHOUT_V }}
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: master
- name: Check Tag Validity
id: validator
run: |
git fetch
TAG=$(git tag --points-at $GITHUB_SHA)
TAG_WITHOUT_V=${TAG:1}
REGEX="^v[0-9]+\.[0-9]+.[0-9]+"
if [[ $TAG =~ $REGEX ]]; then IS_VALID_TAG=1; else IS_VALID_TAG=0; fi;
echo "::set-output name=VALID_TAG::$IS_VALID_TAG"
echo "::set-output name=TAG_VERSION::$TAG"
echo "::set-output name=TAG_VERSION::$TAG"
echo "::set-output name=TAG_VERSION_WITHOUT_V::$TAG_WITHOUT_V"
- name: If valid tag set
if: steps.validator.outputs.VALID_TAG == 1
run: |
echo "Valid Tag Found - Building Desktop App..."
- name: If not valid tag set
if: steps.validator.outputs.VALID_TAG != 1
run: |
echo "Not a Desktop App Release Tag or Invalid one Found - Exiting..."
build-win:
runs-on: windows-2022
needs: [ tag-validation ]
if: needs.tag-validation.outputs.validator == 1
steps:
- name: Prepare GIT
shell: bash
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v3
- uses: actions/checkout@v3
if: ${{ env.TEAM_REPOSITORY != '' }}
with:
repository: ${{ env.TEAM_REPOSITORY }}
ref: main
token: ${{ secrets.GH_TOKEN }}
path: leapp-team
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Inject Team Feature
if: ${{ env.TEAM_REPOSITORY != '' }}
run: |
cd packages/core
npm install
npm run build
cd ../..
mv leapp-team ..
cd ../leapp-team/packages/leapp-team-core
npm run bootstrap
cd ../leapp-team-service
npm install
npm run test
npm run enable-team-features-prod
- name: Build Win desktop app
shell: bash
run: |
cd packages/desktop-app
curl https://asset.noovolari.com/signing-tool/CodeSignTool-v1.2.7-windows.zip --output CodeSignTool-v1.2.7-windows.zip -s
unzip CodeSignTool-v1.2.7-windows.zip
CONFIG_FILE=code_sign_tool.properties
cat "./CodeSignTool-v1.2.7-windows/conf/$CONFIG_FILE"
npm install
npm run release-win
rm -Rf ./release/win-unpacked
rm -Rf ./release/.cache
rm -Rf ./release/builder-debug.yml
rm -Rf ./release/builder-effective-config.yaml
TAG_VERSION=${{ needs.tag-validation.outputs.tag-version }}
TAG_VERSION=${TAG_VERSION:1}
rm "./release/Leapp-${TAG_VERSION}-win.zip" ||:
powershell "Compress-Archive './release/Leapp Setup ${TAG_VERSION}.exe' './release/Leapp-${TAG_VERSION}-win.zip'"
powershell "Compress-Archive './release/Leapp Setup ${TAG_VERSION}.exe' './release/Leapp-windows.zip'"
powershell "Compress-Archive './release/' './release/Leapp-windows-release.zip'"
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: Leapp-windows-release.zip
path: packages/desktop-app/release/Leapp-windows-release.zip
build-linux:
runs-on: ubuntu-latest
needs: [ tag-validation ]
if: needs.tag-validation.outputs.validator == 1
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
if: ${{ env.TEAM_REPOSITORY != '' }}
with:
repository: ${{ env.TEAM_REPOSITORY }}
ref: main
token: ${{ secrets.GH_TOKEN }}
path: leapp-team
- name: Inject Team Feature
if: ${{ env.TEAM_REPOSITORY != '' }}
run: |
cd packages/core
npm install
npm run build
cd ../..
mv leapp-team ..
cd ../leapp-team/packages/leapp-team-core
npm run bootstrap
cd ../leapp-team-service
npm install
npm run test
npm run enable-team-features-prod
- name: Build Linux desktop app
run: |
cd packages/desktop-app
npm install
npm run release-linux
rm -Rf ./release/linux-unpacked
rm -Rf ./release/.cache
rm -Rf ./release/builder-debug.yml
rm -Rf ./release/builder-effective-config.yaml
TAG_VERSION=${{ needs.tag-validation.outputs.tag-version }}
TAG_VERSION=${TAG_VERSION:1}
zip "./release/Leapp-deb.zip" "./release/Leapp_${TAG_VERSION}_amd64.deb"
zip "./release/Leapp-appImage.zip" "./release/Leapp-${TAG_VERSION}.AppImage"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Release draft to S3
run: |
cd packages/desktop-app
TAG_VERSION=${{ needs.tag-validation.outputs.tag-version }}
TAG_VERSION=${TAG_VERSION:1}
aws s3 cp ./release/ "${{ env.S3_BUCKET }}/${TAG_VERSION}/" --recursive
build-macos-x64:
runs-on: macos-latest
needs: [ tag-validation ]
if: needs.tag-validation.outputs.validator == 1
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
if: ${{ env.TEAM_REPOSITORY != '' }}
with:
repository: ${{ env.TEAM_REPOSITORY }}
ref: main
token: ${{ secrets.GH_TOKEN }}
path: leapp-team
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Inject Team Feature
if: ${{ env.TEAM_REPOSITORY != '' }}
run: |
cd packages/core
npm install
npm run build
cd ../..
mv leapp-team ..
cd ../leapp-team/packages/leapp-team-core
npm run bootstrap
cd ../leapp-team-service
npm install
npm run test
npm run enable-team-features-prod
- name: Build macOS x64 desktop app
uses: nick-fields/retry@v2
env:
APPLE_NOTARISATION_PASSWORD: ${{ secrets.APPLE_NOTARISATION_PASSWORD }}
with:
timeout_minutes: 20
max_attempts: 5
command: |
cd packages/desktop-app
KEY_CHAIN=build.keychain
CERTIFICATE_P12=certificate.p12
CERTIFICATE_APPLICATION_P12=certificate-application.p12
echo "Recreate the certificate from the secure environment variable"
echo "security create-keychain"
echo "${{ env.CERTIFICATE_OSX_P12 }}" | base64 --decode > $CERTIFICATE_P12
echo "${{ env.CERTIFICATE_APPLICATION_OSX_P12 }}" | base64 --decode > $CERTIFICATE_APPLICATION_P12
security create-keychain -p ${{ env.KEYCHAIN_PASSWORD }} $KEY_CHAIN
echo "security list-keychains"
security list-keychains -s login.keychain build.keychain
echo "security default-keychain"
security default-keychain -s $KEY_CHAIN
echo "security unlock-keychain"
security unlock-keychain -p ${{ env.KEYCHAIN_PASSWORD }} $KEY_CHAIN
echo "security import"
security import $CERTIFICATE_P12 -k $KEY_CHAIN -P '${{ env.DECODE_PASSWORD }}' -T /usr/bin/codesign;
security import $CERTIFICATE_APPLICATION_P12 -k $KEY_CHAIN -P '${{ env.DECODE_PASSWORD }}' -T /usr/bin/codesign;
echo "security find-identity"
security find-identity -v
echo "security set-key-partition-list"
security set-key-partition-list -S apple-tool:,apple:,codesign:, -s -k ${{ env.KEYCHAIN_PASSWORD }} $KEY_CHAIN
rm -fr *.p12
npm install
npm run set-target-x64
npm run release-mac
- name: Clean build
run: |
cd packages/desktop-app
rm -Rf ./release/mac
rm -Rf ./release/mac-unpacked
rm -Rf ./release/.cache
rm -Rf ./release/builder-debug.yml
rm -Rf ./release/builder-effective-config.yaml
TAG_VERSION=${{ needs.tag-validation.outputs.tag-version }}
TAG_VERSION=${TAG_VERSION:1}
rm "./release/Leapp-${TAG_VERSION}-mac.zip"
rm "./release/Leapp-${TAG_VERSION}-mac.zip.blockmap"
zip "./release/Leapp-${TAG_VERSION}-mac.zip" "./release/Leapp-${TAG_VERSION}.dmg"
zip "./release/Leapp-mac.zip" "./release/Leapp-${TAG_VERSION}.dmg"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Release draft to S3
run: |
cd packages/desktop-app
TAG_VERSION=${{ needs.tag-validation.outputs.tag-version }}
TAG_VERSION=${TAG_VERSION:1}
aws s3 cp ./release/ "${{ env.S3_BUCKET }}/${TAG_VERSION}/" --recursive
build-macos-arm:
runs-on: macos-latest
needs: [ tag-validation, build-macos-x64 ]
if: needs.tag-validation.outputs.validator == 1
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
if: ${{ env.TEAM_REPOSITORY != '' }}
with:
repository: ${{ env.TEAM_REPOSITORY }}
ref: main
token: ${{ secrets.GH_TOKEN }}
path: leapp-team
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Inject Team Feature
if: ${{ env.TEAM_REPOSITORY != '' }}
run: |
cd packages/core
npm install
npm run build
cd ../..
mv leapp-team ..
cd ../leapp-team/packages/leapp-team-core
npm run bootstrap
cd ../leapp-team-service
npm install
npm run test
npm run enable-team-features-prod
- name: Build macOS arm64 desktop app
uses: nick-fields/retry@v2
env:
APPLE_NOTARISATION_PASSWORD: ${{ secrets.APPLE_NOTARISATION_PASSWORD }}
with:
timeout_minutes: 20
max_attempts: 5
command: |
cd packages/desktop-app
KEY_CHAIN=build.keychain
CERTIFICATE_P12=certificate.p12
CERTIFICATE_APPLICATION_P12=certificate-application.p12
echo "Recreate the certificate from the secure environment variable"
echo "security create-keychain"
echo "${{ env.CERTIFICATE_OSX_P12 }}" | base64 --decode > $CERTIFICATE_P12
echo "${{ env.CERTIFICATE_APPLICATION_OSX_P12 }}" | base64 --decode > $CERTIFICATE_APPLICATION_P12
security create-keychain -p ${{ env.KEYCHAIN_PASSWORD }} $KEY_CHAIN
echo "security list-keychains"
security list-keychains -s login.keychain build.keychain
echo "security default-keychain"
security default-keychain -s $KEY_CHAIN
echo "security unlock-keychain"
security unlock-keychain -p ${{ env.KEYCHAIN_PASSWORD }} $KEY_CHAIN
echo "security import"
security import $CERTIFICATE_P12 -k $KEY_CHAIN -P '${{ env.DECODE_PASSWORD }}' -T /usr/bin/codesign;
security import $CERTIFICATE_APPLICATION_P12 -k $KEY_CHAIN -P '${{ env.DECODE_PASSWORD }}' -T /usr/bin/codesign;
echo "security find-identity"
security find-identity -v
echo "security set-key-partition-list"
security set-key-partition-list -S apple-tool:,apple:,codesign:, -s -k ${{ env.KEYCHAIN_PASSWORD }} $KEY_CHAIN
rm -fr *.p12
npm install
npm run set-target-arm64
npm run release-mac
- name: Clean build
run: |
cd packages/desktop-app
rm -Rf ./release/mac
rm -Rf ./release/mac-unpacked
rm -Rf ./release/.cache
rm -Rf ./release/builder-debug.yml
rm -Rf ./release/builder-effective-config.yaml
rm -Rf ./release/mac-arm64
TAG_VERSION=${{ needs.tag-validation.outputs.tag-version }}
TAG_VERSION=${TAG_VERSION:1}
rm "./release/Leapp-${TAG_VERSION}-arm64-mac.zip"
rm "./release/Leapp-${TAG_VERSION}-arm64-mac.zip.blockmap"
zip "./release/Leapp-${TAG_VERSION}-mac-arm64.zip" "./release/Leapp-${TAG_VERSION}-arm64.dmg"
zip "./release/Leapp-arm-mac.zip" "./release/Leapp-${TAG_VERSION}-arm64.dmg"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Release draft to S3
run: |
cd packages/desktop-app
TAG_VERSION=${{ needs.tag-validation.outputs.tag-version }}
TAG_VERSION=${TAG_VERSION:1}
aws s3 cp ./release/ "${{ env.S3_BUCKET }}/${TAG_VERSION}/" --recursive
publish-draft:
runs-on: ubuntu-latest
environment: prod
needs: [ tag-validation, build-linux, build-win, build-macos-arm, build-macos-x64 ]
if: needs.tag-validation.outputs.validator == 1
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Move draft to latest
run: |
TAG_VERSION=${{ needs.tag-validation.outputs.tag-version }}
TAG_VERSION=${TAG_VERSION:1}
aws s3 rm "${{ env.S3_BUCKET }}/latest" --recursive
aws s3 cp "${{ env.S3_BUCKET }}/${TAG_VERSION}/" "${{ env.S3_BUCKET }}/latest" --recursive
publish-changelog:
runs-on: ubuntu-latest
environment: prod
needs: [ publish-draft ]
if: needs.tag-validation.outputs.validator == 1
steps:
- uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Publish changelog
run: |
aws s3 cp CHANGELOG.md "${{ env.S3_BUCKET }}/"
invalidate-distribution:
runs-on: ubuntu-latest
environment: prod
needs: [ publish-changelog ]
if: needs.tag-validation.outputs.validator == 1
steps:
- uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Invalidate distribution
run: |
aws cloudfront create-invalidation --distribution-id ${{ env.DISTRIBUTION_ID }} --paths "/*"
publish-github-release:
runs-on: ubuntu-latest
environment: prod
needs: [ invalidate-distribution, tag-validation ]
if: needs.tag-validation.outputs.validator == 1
steps:
- uses: actions/checkout@v3
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GH_TOKEN }}
body: "Full changelog & Downloads ⇒ https://www.leapp.cloud/releases"
tag: ${{ needs.tag-validation.outputs.tag-version }}