Skip to content

Commit 20fcc7a

Browse files
authored
Merge pull request #142 from arduino/github/windows-signing-2024
GitHub/windows signing 2024
2 parents 819a6dd + 274930a commit 20fcc7a

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414

1515
env:
1616
JOB_TRANSFER_ARTIFACT: build-artifacts
17+
NODE_VERSION: 18.17
1718

1819
jobs:
1920
build:
@@ -22,7 +23,7 @@ jobs:
2223
fail-fast: false
2324
matrix:
2425
config:
25-
- os: windows-2019
26+
- os: [self-hosted, windows-sign-pc]
2627
- os: ubuntu-latest
2728
- os: macos-13
2829
- os: macos-14
@@ -31,15 +32,17 @@ jobs:
3132

3233
steps:
3334
- name: Checkout
34-
uses: actions/checkout@v3
35+
uses: actions/checkout@v4
3536

36-
- name: Install Node.js 16.x
37-
uses: actions/setup-node@v3
37+
- name: Install Node.js ${{ env.NODE_VERSION }}
38+
if: runner.name != 'WINDOWS-SIGN-PC'
39+
uses: actions/setup-node@v4
3840
with:
39-
node-version: '16'
41+
node-version: ${{ env.NODE_VERSION }}
4042
registry-url: 'https://registry.npmjs.org'
4143

4244
- name: Install Python 3.x
45+
if: runner.name != 'WINDOWS-SIGN-PC'
4346
uses: actions/setup-python@v4
4447
with:
4548
python-version: '3.11.x'
@@ -51,11 +54,18 @@ jobs:
5154
AC_USERNAME: ${{ secrets.AC_USERNAME }}
5255
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
5356
AC_TEAM_ID: ${{ secrets.AC_TEAM_ID }}
57+
INSTALLER_CERT_WINDOWS_CER: "/tmp/cert.cer"
58+
# We are hardcoding the path for signtool because is not present on the windows PATH env var by default.
59+
# Keep in mind that this path could change when upgrading to a new runner version
60+
SIGNTOOL_PATH: "C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x86/signtool.exe"
61+
WIN_CERT_PASSWORD: ${{ secrets.INSTALLER_CERT_WINDOWS_PASSWORD }}
62+
WIN_CERT_CONTAINER_NAME: ${{ secrets.INSTALLER_CERT_WINDOWS_CONTAINER }}
5463
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
5564
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
5665
# IS_NIGHTLY: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') }}
5766
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }}
5867
IS_FORK: ${{ github.event.pull_request.head.repo.fork == true }}
68+
5969
run: |
6070
# See: https://www.electron.build/code-signing
6171
if [ $IS_FORK = true ]; then

build_resources/windowsCustomSign.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const childProcess = require('child_process');
2+
3+
exports.default = async function (configuration) {
4+
if (!process.env.GITHUB_ACTIONS) {
5+
return;
6+
}
7+
8+
const SIGNTOOL_PATH = process.env.SIGNTOOL_PATH;
9+
const INSTALLER_CERT_WINDOWS_CER = process.env.INSTALLER_CERT_WINDOWS_CER;
10+
const CERT_PASSWORD = process.env.WIN_CERT_PASSWORD;
11+
const CONTAINER_NAME = process.env.WIN_CERT_CONTAINER_NAME;
12+
const filePath = configuration.path;
13+
14+
if (
15+
SIGNTOOL_PATH &&
16+
INSTALLER_CERT_WINDOWS_CER &&
17+
CERT_PASSWORD &&
18+
CONTAINER_NAME
19+
) {
20+
childProcess.execSync(
21+
`"${SIGNTOOL_PATH}" sign -d "Arduino Lab for MicroPython" -f "${INSTALLER_CERT_WINDOWS_CER}" -csp "eToken Base Cryptographic Provider" -k "[{{${CERT_PASSWORD}}}]=${CONTAINER_NAME}" -fd sha256 -tr http://timestamp.digicert.com -td SHA256 -v "${filePath}"`,
22+
{ stdio: 'inherit' }
23+
);
24+
} else {
25+
console.warn(
26+
`Custom windows signing was no performed one of the following variables was not provided: SIGNTOOL_PATH (${SIGNTOOL_PATH}), INSTALLER_CERT_WINDOWS_CERT (${INSTALLER_CERT_WINDOWS_CER}), CERT_PASSWORD (${CERT_PASSWORD}), CONTAINER_NAME (${CONTAINER_NAME})`
27+
);
28+
process.exit(1);
29+
}
30+
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"win": {
3030
"target": "zip",
31+
"sign": "./build_resources/windowsCustomSign.js",
3132
"icon": "build_resources/icon.png"
3233
},
3334
"linux": {

0 commit comments

Comments
 (0)