Skip to content

Commit 1fc326e

Browse files
use container for signing
1 parent 1836f6b commit 1fc326e

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

.github/workflows/build.yml

+22-2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ env:
6666
certificate-password-secret: INSTALLER_CERT_WINDOWS_PASSWORD
6767
# File extension for the certificate.
6868
certificate-extension: pfx
69+
# Container for windows cert signing
70+
certificate-container: INSTALLER_CERT_WINDOWS_CONTAINER
6971
# Quoting on the value is required here to allow the same comparison expression syntax to be used for this
7072
# and the companion needs.select-targets.outputs.merge-channel-files property (output values always have string
7173
# type).
@@ -270,6 +272,13 @@ jobs:
270272
env:
271273
# Location of artifacts generated by build.
272274
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/x86/signtool.exe"
280+
CERT_PASSWORD: ${{ secrets[matrix.config.certificate-password-secret] }}
281+
CONTAINER_NAME: ${{ secrets[matrix.config.certificate-container] }}
273282
strategy:
274283
matrix:
275284
config: ${{ fromJson(needs.select-targets.outputs.build-matrix) }}
@@ -352,7 +361,7 @@ jobs:
352361
CREATE_CLIENT_SECRET: ${{ secrets.CREATE_CLIENT_SECRET }}
353362
run: |
354363
# See: https://www.electron.build/code-signing
355-
if [ $CAN_SIGN = false ]; then
364+
if [ $CAN_SIGN = false ] || [ $IS_WINDOWS_CONFIG = true ]; then
356365
echo "Skipping the app signing: certificate not provided."
357366
else
358367
export CSC_LINK="${{ runner.temp }}/signing_certificate.${{ matrix.config.certificate-extension }}"
@@ -371,8 +380,19 @@ jobs:
371380
372381
yarn --cwd electron-app rebuild
373382
yarn --cwd electron-app build
374-
yarn --cwd electron-app package
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 }}
375389
390+
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+
376396
# Both macOS jobs generate a "channel update info file" with same path and name. The second job to complete would
377397
# overwrite the file generated by the first in the workflow artifact.
378398
- name: Stage channel file for merge

0 commit comments

Comments
 (0)