Skip to content

Commit e7ddc2d

Browse files
create separate job for signing
1 parent 05d801c commit e7ddc2d

File tree

1 file changed

+56
-20
lines changed

1 file changed

+56
-20
lines changed

.github/workflows/build.yml

+56-20
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,6 @@ jobs:
272272
env:
273273
# Location of artifacts generated by build.
274274
BUILD_ARTIFACTS_PATH: electron-app/dist/build-artifacts
275-
IS_WINDOWS_CONFIG: ${{ matrix.config.name == 'Windows' }}
276-
INSTALLER_CERT_WINDOWS_CER: "/tmp/cert.cer"
277-
# We are hardcoding the path for signtool because is not present on the windows PATH env var by default.
278-
# Keep in mind that this path could change when upgrading to a new runner version
279-
SIGNTOOL_PATH: "C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x64/signtool.exe"
280-
CERT_PASSWORD: ${{ secrets[matrix.config.certificate-password-secret] }}
281-
CONTAINER_NAME: ${{ secrets[matrix.config.certificate-container] }}
282275
strategy:
283276
matrix:
284277
config: ${{ fromJson(needs.select-targets.outputs.build-matrix) }}
@@ -380,19 +373,8 @@ jobs:
380373
381374
yarn --cwd electron-app rebuild
382375
yarn --cwd electron-app build
383-
yarn --cwd electron-app
384-
385-
- name: Save Windows signing certificate to file
386-
if: ${{ matrix.config.name == 'Windows' }}
387-
run: |
388-
echo "${{ secrets[matrix.config.certificate-secret] }}" | base64 --decode > ${{ env.INSTALLER_CERT_WINDOWS_CER }}
389-
376+
yarn --cwd electron-app
390377
391-
- name: Sign Windows EXE
392-
if: ${{ matrix.config.name == 'Windows' }}
393-
run: |
394-
"${{ 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 ${{ env.BUILD_ARTIFACTS_PATH }}/*."exe"
395-
396378
# Both macOS jobs generate a "channel update info file" with same path and name. The second job to complete would
397379
# overwrite the file generated by the first in the workflow artifact.
398380
- name: Stage channel file for merge
@@ -425,12 +407,61 @@ jobs:
425407
with:
426408
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
427409
path: ${{ env.BUILD_ARTIFACTS_PATH }}
428-
410+
411+
sign-windows:
412+
runs-on: [self-hosted, windows-sign-pc]
413+
needs: build
414+
415+
defaults:
416+
run:
417+
shell: bash
418+
419+
env:
420+
INSTALLER_CERT_WINDOWS_CER: "/tmp/cert.cer"
421+
# We are hardcoding the path for signtool because is not present on the windows PATH env var by default.
422+
# Keep in mind that this path could change when upgrading to a new runner version
423+
SIGNTOOL_PATH: "C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x86/signtool.exe"
424+
425+
steps:
426+
- name: Download artifact
427+
uses: actions/download-artifact@v3
428+
with:
429+
name: Windows_X86-64_interactive_installer
430+
431+
- name: Save artifact path to variable
432+
run: |
433+
# Find the artifact ending with 'Windows_64bit.exe' in the specified download directory
434+
ARTIFACT_PATH=$(find . -name "*Windows_64bit.exe")
435+
echo "ARTIFACT_PATH=${ARTIFACT_PATH}" >> $GITHUB_ENV
436+
437+
- name: Save Win signing certificate to file
438+
run: echo "${{ secrets[matrix.config.certificate-secret] }}" | base64 --decode > ${{ env.INSTALLER_CERT_WINDOWS_CER }}
439+
440+
- name: Sign EXE
441+
env:
442+
CERT_PASSWORD: ${{ secrets[matrix.config.certificate-password-secret] }}
443+
CONTAINER_NAME: ${{ secrets[matrix.config.certificate-container] }}
444+
# https://stackoverflow.com/questions/17927895/automate-extended-validation-ev-code-signing-with-safenet-etoken
445+
run: |
446+
"${{ 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 ${{ env.ARTIFACT_PATH }}"
447+
448+
# upload signed exe to artifacts overwriting existing
449+
- name: Upload signed EXE
450+
uses: actions/upload-artifact@v3
451+
with:
452+
name: Windows_X86-64_interactive_installer
453+
path: ${{ env.ARTIFACT_PATH }}
454+
455+
# This step is needed because the self hosted runner does not delete files automatically
456+
- name: Clean up EXE
457+
run: rm ${{ env.ARTIFACT_PATH }}
458+
429459
merge-channel-files:
430460
needs:
431461
- build-type-determination
432462
- select-targets
433463
- build
464+
- sign-windows
434465
if: needs.select-targets.outputs.merge-channel-files == 'true'
435466
runs-on: ubuntu-latest
436467
permissions: {}
@@ -494,6 +525,7 @@ jobs:
494525
needs:
495526
- select-targets
496527
- build
528+
- sign-windows
497529
if: always() && needs.build.result != 'skipped'
498530
runs-on: ubuntu-latest
499531

@@ -518,6 +550,7 @@ jobs:
518550
needs:
519551
- build-type-determination
520552
- build
553+
- sign-windows
521554
runs-on: ubuntu-latest
522555
outputs:
523556
BODY: ${{ steps.changelog.outputs.BODY }}
@@ -567,6 +600,7 @@ jobs:
567600
- build-type-determination
568601
- merge-channel-files
569602
- changelog
603+
- sign-windows
570604
if: >
571605
always() &&
572606
needs.build-type-determination.result == 'success' &&
@@ -600,6 +634,7 @@ jobs:
600634
- build-type-determination
601635
- merge-channel-files
602636
- changelog
637+
- sign-windows
603638
if: >
604639
always() &&
605640
needs.build-type-determination.result == 'success' &&
@@ -651,6 +686,7 @@ jobs:
651686
- publish
652687
- release
653688
- artifacts
689+
- sign-windows
654690
if: always() && needs.build.result != 'skipped'
655691
runs-on: ubuntu-latest
656692

0 commit comments

Comments
 (0)