61
61
container: |
62
62
null
63
63
# Name of the secret that contains the certificate.
64
- certificate-secret: WINDOWS_SIGNING_CERTIFICATE_PFX
64
+ certificate-secret: INSTALLER_CERT_WINDOWS_CER
65
65
# Name of the secret that contains the certificate password.
66
- certificate-password-secret: WINDOWS_SIGNING_CERTIFICATE_PASSWORD
66
+ certificate-password-secret: INSTALLER_CERT_WINDOWS_PASSWORD
67
67
# File extension for the certificate.
68
68
certificate-extension: pfx
69
+ # Container for windows cert signing
70
+ certificate-container: INSTALLER_CERT_WINDOWS_CONTAINER
69
71
# Quoting on the value is required here to allow the same comparison expression syntax to be used for this
70
72
# and the companion needs.select-targets.outputs.merge-channel-files property (output values always have string
71
73
# type).
72
74
mergeable-channel-file: 'false'
73
75
artifacts:
74
76
- path: '*Windows_64bit.exe'
75
77
name: Windows_X86-64_interactive_installer
78
+ - path: '*Windows_64bit_unsigned.exe'
79
+ name: Windows_X86-64_interactive_installer_unsigned
76
80
- path: '*Windows_64bit.msi'
77
81
name: Windows_X86-64_MSI
82
+ - path: '*Windows_64bit_unsigned.msi'
83
+ name: Windows_X86-64_MSI_unsigned
78
84
- path: '*Windows_64bit.zip'
79
85
name: Windows_X86-64_zip
86
+ - path: '*Windows_64bit_unsigned.zip'
87
+ name: Windows_X86-64_zip_unsigned
80
88
- config:
81
89
name: Linux
82
90
runs-on: ubuntu-latest
@@ -345,14 +353,15 @@ jobs:
345
353
IS_NIGHTLY : ${{ needs.build-type-determination.outputs.is-nightly }}
346
354
IS_RELEASE : ${{ needs.build-type-determination.outputs.is-release }}
347
355
CAN_SIGN : ${{ secrets[matrix.config.certificate-secret] != '' }}
356
+ IS_WINDOWS_CONFIG : ${{ matrix.config.name == 'Windows' }}
348
357
# The CREATE_* environment vars are only used to run tests. These secrets are optional. Dependent tests will
349
358
# be skipped if not available.
350
359
CREATE_USERNAME : ${{ secrets.CREATE_USERNAME }}
351
360
CREATE_PASSWORD : ${{ secrets.CREATE_PASSWORD }}
352
361
CREATE_CLIENT_SECRET : ${{ secrets.CREATE_CLIENT_SECRET }}
353
362
run : |
354
363
# See: https://www.electron.build/code-signing
355
- if [ $CAN_SIGN = false ]; then
364
+ if [ $CAN_SIGN = false ] || [ $IS_WINDOWS_CONFIG = true ] ; then
356
365
echo "Skipping the app signing: certificate not provided."
357
366
else
358
367
export CSC_LINK="${{ runner.temp }}/signing_certificate.${{ matrix.config.certificate-extension }}"
@@ -372,7 +381,7 @@ jobs:
372
381
yarn --cwd electron-app rebuild
373
382
yarn --cwd electron-app build
374
383
yarn --cwd electron-app package
375
-
384
+
376
385
# Both macOS jobs generate a "channel update info file" with same path and name. The second job to complete would
377
386
# overwrite the file generated by the first in the workflow artifact.
378
387
- name : Stage channel file for merge
@@ -406,11 +415,76 @@ jobs:
406
415
name : ${{ env.JOB_TRANSFER_ARTIFACT }}
407
416
path : ${{ env.BUILD_ARTIFACTS_PATH }}
408
417
418
+ sign-windows :
419
+ runs-on : [self-hosted, windows-sign-pc]
420
+ needs : build
421
+
422
+ defaults :
423
+ run :
424
+ shell : bash
425
+
426
+ env :
427
+ BUILD_ARTIFACTS_PATH : electron-app/dist/build-artifacts
428
+ INSTALLER_CERT_WINDOWS_CER : " /tmp/cert.cer"
429
+ # We are hardcoding the path for signtool because is not present on the windows PATH env var by default.
430
+ # Keep in mind that this path could change when upgrading to a new runner version
431
+ SIGNTOOL_PATH : " C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x86/signtool.exe"
432
+
433
+ steps :
434
+ - name : Download artifact
435
+ uses : actions/download-artifact@v3
436
+ with :
437
+ name : ${{ env.JOB_TRANSFER_ARTIFACT }}
438
+ path : ${{ env.BUILD_ARTIFACTS_PATH }}
439
+
440
+ - name : Find and process exe and msi artifacts
441
+ shell : bash
442
+ env :
443
+ CERT_PASSWORD : ${{ secrets.INSTALLER_CERT_WINDOWS_PASSWORD }}
444
+ CONTAINER_NAME : ${{ secrets.INSTALLER_CERT_WINDOWS_CONTAINER }}
445
+ # https://stackoverflow.com/questions/17927895/automate-extended-validation-ev-code-signing-with-safenet-etoken
446
+ run : |
447
+ shopt -s nullglob
448
+ for ARTIFACT in "${{ env.BUILD_ARTIFACTS_PATH }}"/*_unsigned.{exe,msi}; do
449
+ echo "Processing $ARTIFACT"
450
+ FILENAME=$(basename "$ARTIFACT")
451
+ BASE_NAME="${FILENAME%.*}"
452
+ EXTENSION="${FILENAME##*.}"
453
+ # Remove '_unsigned' from the base name
454
+ SIGNED_BASE_NAME="${BASE_NAME%_unsigned}"
455
+
456
+ # Sign and rename EXE and MSI files
457
+ if [[ "$EXTENSION" == "exe" || "$EXTENSION" == "msi" ]]; then
458
+ echo "Signing $ARTIFACT"
459
+ "${{ env.SIGNTOOL_PATH }}" sign -d "Arduino IDE" -f ${{ env.INSTALLER_CERT_WINDOWS_CER }} -csp "eToken Base Cryptographic Provider" -k "[{{${{ env.CERT_PASSWORD }}}}]=${{ env.CONTAINER_NAME }}" -fd sha256 -tr http://timestamp.digicert.com -td SHA256 -v "$ARTIFACT"
460
+ SIGNED_ARTIFACT_PATH="${{ env.BUILD_ARTIFACTS_PATH }}/${SIGNED_BASE_NAME}.${EXTENSION}"
461
+ mv "$ARTIFACT" "$SIGNED_ARTIFACT_PATH"
462
+ echo "Renamed $ARTIFACT to $SIGNED_ARTIFACT_PATH"
463
+ fi
464
+ done
465
+
466
+ - name : Upload signed EXE
467
+ uses : actions/upload-artifact@v3
468
+ with :
469
+ name : Windows_X86-64_interactive_installer
470
+ path : ${{ env.BUILD_ARTIFACTS_PATH }}/*Windows_64bit.exe
471
+
472
+ - name : Upload signed MSI
473
+ uses : actions/upload-artifact@v3
474
+ with :
475
+ name : Windows_X86-64_MSI
476
+ path : ${{ env.BUILD_ARTIFACTS_PATH }}/*Windows_64bit.msi
477
+
478
+ # This step is needed because the self hosted runner does not delete files automatically
479
+ - name : Clean up artifacts
480
+ run : rm -rf ${{ env.BUILD_ARTIFACTS_PATH }}
481
+
409
482
merge-channel-files :
410
483
needs :
411
484
- build-type-determination
412
485
- select-targets
413
486
- build
487
+ - sign-windows
414
488
if : needs.select-targets.outputs.merge-channel-files == 'true'
415
489
runs-on : ubuntu-latest
416
490
permissions : {}
@@ -474,6 +548,7 @@ jobs:
474
548
needs :
475
549
- select-targets
476
550
- build
551
+ - sign-windows
477
552
if : always() && needs.build.result != 'skipped'
478
553
runs-on : ubuntu-latest
479
554
@@ -498,6 +573,7 @@ jobs:
498
573
needs :
499
574
- build-type-determination
500
575
- build
576
+ - sign-windows
501
577
runs-on : ubuntu-latest
502
578
outputs :
503
579
BODY : ${{ steps.changelog.outputs.BODY }}
@@ -547,6 +623,7 @@ jobs:
547
623
- build-type-determination
548
624
- merge-channel-files
549
625
- changelog
626
+ - sign-windows
550
627
if : >
551
628
always() &&
552
629
needs.build-type-determination.result == 'success' &&
@@ -580,6 +657,7 @@ jobs:
580
657
- build-type-determination
581
658
- merge-channel-files
582
659
- changelog
660
+ - sign-windows
583
661
if : >
584
662
always() &&
585
663
needs.build-type-determination.result == 'success' &&
@@ -631,6 +709,7 @@ jobs:
631
709
- publish
632
710
- release
633
711
- artifacts
712
+ - sign-windows
634
713
if : always() && needs.build.result != 'skipped'
635
714
runs-on : ubuntu-latest
636
715
0 commit comments