Skip to content

Commit 45444ad

Browse files
committed
Testing local runner signing for Windows.
Signed-off-by: ubi de feo <[email protected]>
1 parent ae2c82a commit 45444ad

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

.github/workflows/build.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
config:
25-
- os: windows-2019
25+
- os: [self-hosted, windows-sign-pc]
2626
- os: ubuntu-latest
2727
- os: macos-13
2828
- os: macos-14
@@ -51,11 +51,18 @@ jobs:
5151
AC_USERNAME: ${{ secrets.AC_USERNAME }}
5252
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
5353
AC_TEAM_ID: ${{ secrets.AC_TEAM_ID }}
54+
INSTALLER_CERT_WINDOWS_CER: "/tmp/cert.cer"
55+
# We are hardcoding the path for signtool because is not present on the windows PATH env var by default.
56+
# Keep in mind that this path could change when upgrading to a new runner version
57+
SIGNTOOL_PATH: "C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x86/signtool.exe"
58+
WIN_CERT_PASSWORD: ${{ secrets.INSTALLER_CERT_WINDOWS_PASSWORD }}
59+
WIN_CERT_CONTAINER_NAME: ${{ secrets.INSTALLER_CERT_WINDOWS_CONTAINER }}
5460
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
5561
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
5662
# IS_NIGHTLY: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') }}
5763
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }}
5864
IS_FORK: ${{ github.event.pull_request.head.repo.fork == true }}
65+
5966
run: |
6067
# See: https://www.electron.build/code-signing
6168
if [ $IS_FORK = true ]; then

build_resources/windowsCustomSign.js

+30
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

+1
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)