Skip to content

Commit d1aa446

Browse files
committed
Refactor signing certificate handling in "Arduino IDE" workflow
Previously, there was some code duplication of the complex code signing certificate handling commands, which made the related code more difficult to understand, maintain, and develop. The cause of this duplication is that there is a separate certificate for each operating system, each of which is stored in separate repository secrets, as well as a different certificate file extension for each OS. Since the secret names and file extensions are associated with the operating system, it is most logical to define them via attributes alongside the operating system definition in the job matrix configuration already used to generate the parallel job runs for native build on each OS. That done, the certificate handling commands are universal and the system can easily expand to additional host targets (e.g., Apple M1) as time goes on.
1 parent e454acb commit d1aa446

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

Diff for: .github/workflows/build.yml

+15-15
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,22 @@ env:
1717

1818
jobs:
1919
build:
20+
name: build (${{ matrix.config.os }})
2021
if: github.repository == 'arduino/arduino-ide'
2122
strategy:
2223
matrix:
2324
config:
2425
- os: windows-2019
26+
certificate-secret: WINDOWS_SIGNING_CERTIFICATE_PFX # Name of the secret that contains the certificate.
27+
certificate-password-secret: WINDOWS_SIGNING_CERTIFICATE_PASSWORD # Name of the secret that contains the certificate password.
28+
certificate-extension: pfx # File extension for the certificate.
2529
- os: ubuntu-18.04 # https://github.com/arduino/arduino-ide/issues/259
2630
- os: macos-latest
31+
# APPLE_SIGNING_CERTIFICATE_P12 secret was produced by following the procedure from:
32+
# https://www.kencochrane.com/2020/08/01/build-and-sign-golang-binaries-for-macos-with-github-actions/#exporting-the-developer-certificate
33+
certificate-secret: APPLE_SIGNING_CERTIFICATE_P12
34+
certificate-password-secret: KEYCHAIN_PASSWORD
35+
certificate-extension: p12
2736
runs-on: ${{ matrix.config.os }}
2837
timeout-minutes: 90
2938

@@ -59,23 +68,14 @@ jobs:
5968
if [ $IS_FORK = true ]; then
6069
echo "Skipping the app signing: building from a fork."
6170
else
62-
if [ "${{ runner.OS }}" = "macOS" ]; then
63-
export CSC_LINK="${{ runner.temp }}/signing_certificate.p12"
64-
# APPLE_SIGNING_CERTIFICATE_P12 secret was produced by following the procedure from:
65-
# https://www.kencochrane.com/2020/08/01/build-and-sign-golang-binaries-for-macos-with-github-actions/#exporting-the-developer-certificate
66-
echo "${{ secrets.APPLE_SIGNING_CERTIFICATE_P12 }}" | base64 --decode > "$CSC_LINK"
67-
68-
export CSC_KEY_PASSWORD="${{ secrets.KEYCHAIN_PASSWORD }}"
69-
70-
elif [ "${{ runner.OS }}" = "Windows" ]; then
71-
export CSC_LINK="${{ runner.temp }}/signing_certificate.pfx"
72-
npm config set msvs_version 2017 --global
73-
echo "${{ secrets.WINDOWS_SIGNING_CERTIFICATE_PFX }}" | base64 --decode > "$CSC_LINK"
74-
75-
export CSC_KEY_PASSWORD="${{ secrets.WINDOWS_SIGNING_CERTIFICATE_PASSWORD }}"
76-
fi
71+
export CSC_LINK="${{ runner.temp }}/signing_certificate.${{ matrix.config.certificate-extension }}"
72+
echo "${{ secrets[matrix.config.certificate-secret] }}" | base64 --decode > "$CSC_LINK"
73+
export CSC_KEY_PASSWORD="${{ secrets[matrix.config.certificate-password-secret] }}"
7774
fi
7875
76+
if [ "${{ runner.OS }}" = "Windows" ]; then
77+
npm config set msvs_version 2017 --global
78+
fi
7979
npx node-gyp install
8080
yarn --cwd ./electron/packager/
8181
yarn --cwd ./electron/packager/ package

0 commit comments

Comments
 (0)