Skip to content

Commit e7f7b71

Browse files
build ide on self hosted runner
1 parent c1f1885 commit e7f7b71

File tree

3 files changed

+36
-85
lines changed

3 files changed

+36
-85
lines changed

.github/workflows/build.yml

+8-84
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ env:
5555
- config:
5656
# Human identifier for the job.
5757
name: Windows
58-
runs-on: windows-2019
58+
runs-on: [self-hosted, windows-sign-pc]
5959
# The value is a string representing a JSON document.
6060
# Setting this to null causes the job to run directly in the runner machine instead of in a container.
6161
container: |
@@ -75,16 +75,10 @@ env:
7575
artifacts:
7676
- path: '*Windows_64bit.exe'
7777
name: Windows_X86-64_interactive_installer
78-
- path: '*Windows_64bit_unsigned.exe'
79-
name: Windows_X86-64_interactive_installer_unsigned
8078
- path: '*Windows_64bit.msi'
8179
name: Windows_X86-64_MSI
82-
- path: '*Windows_64bit_unsigned.msi'
83-
name: Windows_X86-64_MSI_unsigned
8480
- path: '*Windows_64bit.zip'
8581
name: Windows_X86-64_zip
86-
- path: '*Windows_64bit_unsigned.zip'
87-
name: Windows_X86-64_zip_unsigned
8882
- config:
8983
name: Linux
9084
runs-on: ubuntu-latest
@@ -278,6 +272,7 @@ jobs:
278272
env:
279273
# Location of artifacts generated by build.
280274
BUILD_ARTIFACTS_PATH: electron-app/dist/build-artifacts
275+
IS_WINDOWS_CONFIG: ${{ matrix.config.name == 'Windows' }}
281276
strategy:
282277
matrix:
283278
config: ${{ fromJson(needs.select-targets.outputs.build-matrix) }}
@@ -301,42 +296,42 @@ jobs:
301296
uses: actions/checkout@v3
302297

303298
- name: Install Node.js
304-
if: fromJSON(matrix.config.container) == null
299+
if: fromJSON(matrix.config.container) == null && env.IS_WINDOWS_CONFIG == false
305300
uses: actions/setup-node@v4
306301
with:
307302
node-version: ${{ env.NODE_VERSION }}
308303
registry-url: 'https://registry.npmjs.org'
309304
cache: 'yarn'
310305

311306
- name: Install Python 3.x
312-
if: fromJSON(matrix.config.container) == null
307+
if: fromJSON(matrix.config.container) == null && env.IS_WINDOWS_CONFIG == false
313308
uses: actions/setup-python@v5
314309
with:
315310
python-version: '3.11.x'
316311

317312
- name: Install Go
318-
if: fromJSON(matrix.config.container) == null
313+
if: fromJSON(matrix.config.container) == null && env.IS_WINDOWS_CONFIG == false
319314
uses: actions/setup-go@v5
320315
with:
321316
go-version: ${{ env.GO_VERSION }}
322317

323318
- name: Install Go
324319
# actions/setup-go@v5 has dependency on a higher version of glibc than available in the Linux container.
325-
if: fromJSON(matrix.config.container) != null
320+
if: fromJSON(matrix.config.container) != null && env.IS_WINDOWS_CONFIG == false
326321
uses: actions/setup-go@v4
327322
with:
328323
go-version: ${{ env.GO_VERSION }}
329324

330325
- name: Install Taskfile
331-
if: fromJSON(matrix.config.container) == null
326+
if: fromJSON(matrix.config.container) == null && env.IS_WINDOWS_CONFIG == false
332327
uses: arduino/setup-task@v2
333328
with:
334329
repo-token: ${{ secrets.GITHUB_TOKEN }}
335330
version: 3.x
336331

337332
- name: Install Taskfile
338333
# actions/setup-task@v2 has dependency on a higher version of glibc than available in the Linux container.
339-
if: fromJSON(matrix.config.container) != null
334+
if: fromJSON(matrix.config.container) != null && env.IS_WINDOWS_CONFIG == false
340335
uses: arduino/setup-task@v1
341336
with:
342337
repo-token: ${{ secrets.GITHUB_TOKEN }}
@@ -353,7 +348,6 @@ jobs:
353348
IS_NIGHTLY: ${{ needs.build-type-determination.outputs.is-nightly }}
354349
IS_RELEASE: ${{ needs.build-type-determination.outputs.is-release }}
355350
CAN_SIGN: ${{ secrets[matrix.config.certificate-secret] != '' }}
356-
IS_WINDOWS_CONFIG: ${{ matrix.config.name == 'Windows' }}
357351
# The CREATE_* environment vars are only used to run tests. These secrets are optional. Dependent tests will
358352
# be skipped if not available.
359353
CREATE_USERNAME: ${{ secrets.CREATE_USERNAME }}
@@ -415,76 +409,11 @@ jobs:
415409
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
416410
path: ${{ env.BUILD_ARTIFACTS_PATH }}
417411

418-
sign-windows:
419-
runs-on: [self-hosted, windows-sign-pc]
420-
needs: build
421-
422-
defaults:
423-
run:
424-
shell: bash
425-
426-
env:
427-
BUILD_ARTIFACTS_PATH: electron-app/dist/build-artifacts
428-
INSTALLER_CERT_WINDOWS_CER: "/tmp/cert.cer"
429-
# We are hardcoding the path for signtool because is not present on the windows PATH env var by default.
430-
# Keep in mind that this path could change when upgrading to a new runner version
431-
SIGNTOOL_PATH: "C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x86/signtool.exe"
432-
433-
steps:
434-
- name: Download artifact
435-
uses: actions/download-artifact@v3
436-
with:
437-
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
438-
path: ${{ env.BUILD_ARTIFACTS_PATH }}
439-
440-
- name: Find and process exe and msi artifacts
441-
shell: bash
442-
env:
443-
CERT_PASSWORD: ${{ secrets.INSTALLER_CERT_WINDOWS_PASSWORD }}
444-
CONTAINER_NAME: ${{ secrets.INSTALLER_CERT_WINDOWS_CONTAINER }}
445-
# https://stackoverflow.com/questions/17927895/automate-extended-validation-ev-code-signing-with-safenet-etoken
446-
run: |
447-
shopt -s nullglob
448-
for ARTIFACT in "${{ env.BUILD_ARTIFACTS_PATH }}"/*_unsigned.{exe,msi}; do
449-
echo "Processing $ARTIFACT"
450-
FILENAME=$(basename "$ARTIFACT")
451-
BASE_NAME="${FILENAME%.*}"
452-
EXTENSION="${FILENAME##*.}"
453-
# Remove '_unsigned' from the base name
454-
SIGNED_BASE_NAME="${BASE_NAME%_unsigned}"
455-
456-
# Sign and rename EXE and MSI files
457-
if [[ "$EXTENSION" == "exe" || "$EXTENSION" == "msi" ]]; then
458-
echo "Signing $ARTIFACT"
459-
"${{ 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 "$ARTIFACT"
460-
SIGNED_ARTIFACT_PATH="${{ env.BUILD_ARTIFACTS_PATH }}/${SIGNED_BASE_NAME}.${EXTENSION}"
461-
mv "$ARTIFACT" "$SIGNED_ARTIFACT_PATH"
462-
echo "Renamed $ARTIFACT to $SIGNED_ARTIFACT_PATH"
463-
fi
464-
done
465-
466-
- name: Upload signed EXE
467-
uses: actions/upload-artifact@v3
468-
with:
469-
name: Windows_X86-64_interactive_installer
470-
path: ${{ env.BUILD_ARTIFACTS_PATH }}/*Windows_64bit.exe
471-
472-
- name: Upload signed MSI
473-
uses: actions/upload-artifact@v3
474-
with:
475-
name: Windows_X86-64_MSI
476-
path: ${{ env.BUILD_ARTIFACTS_PATH }}/*Windows_64bit.msi
477-
478-
# This step is needed because the self hosted runner does not delete files automatically
479-
- name: Clean up artifacts
480-
run: rm -rf ${{ env.BUILD_ARTIFACTS_PATH }}
481-
482412
merge-channel-files:
483413
needs:
484414
- build-type-determination
485415
- select-targets
486416
- build
487-
- sign-windows
488417
if: needs.select-targets.outputs.merge-channel-files == 'true'
489418
runs-on: ubuntu-latest
490419
permissions: {}
@@ -548,7 +477,6 @@ jobs:
548477
needs:
549478
- select-targets
550479
- build
551-
- sign-windows
552480
if: always() && needs.build.result != 'skipped'
553481
runs-on: ubuntu-latest
554482

@@ -573,7 +501,6 @@ jobs:
573501
needs:
574502
- build-type-determination
575503
- build
576-
- sign-windows
577504
runs-on: ubuntu-latest
578505
outputs:
579506
BODY: ${{ steps.changelog.outputs.BODY }}
@@ -623,7 +550,6 @@ jobs:
623550
- build-type-determination
624551
- merge-channel-files
625552
- changelog
626-
- sign-windows
627553
if: >
628554
always() &&
629555
needs.build-type-determination.result == 'success' &&
@@ -657,7 +583,6 @@ jobs:
657583
- build-type-determination
658584
- merge-channel-files
659585
- changelog
660-
- sign-windows
661586
if: >
662587
always() &&
663588
needs.build-type-determination.result == 'success' &&
@@ -709,7 +634,6 @@ jobs:
709634
- publish
710635
- release
711636
- artifacts
712-
- sign-windows
713637
if: always() && needs.build.result != 'skipped'
714638
runs-on: ubuntu-latest
715639

electron-app/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@
133133
"msi",
134134
"nsis",
135135
"zip"
136-
]
136+
],
137+
"sign": "./scripts/windowsCustomSign.js"
137138
},
138139
"mac": {
139140
"darkModeSupport": true,
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const childProcess = require('child_process');
2+
3+
exports.default = async function (configuration) {
4+
const SIGNTOOL_PATH = process.env.SIGNTOOL_PATH;
5+
const INSTALLER_CERT_WINDOWS_CER = process.env.INSTALLER_CERT_WINDOWS_CER;
6+
const CERT_PASSWORD = process.env.CERT_PASSWORD;
7+
const CONTAINER_NAME = process.env.CONTAINER_NAME;
8+
const filePath = configuration.path;
9+
10+
if (
11+
SIGNTOOL_PATH &&
12+
INSTALLER_CERT_WINDOWS_CER &&
13+
CERT_PASSWORD &&
14+
CONTAINER_NAME
15+
) {
16+
childProcess.execSync(
17+
`"${SIGNTOOL_PATH}" sign -d "Arduino IDE" -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}"`,
18+
{ stdio: 'inherit' }
19+
);
20+
} else {
21+
console.warn(
22+
'Custom windows signing was no performed: SIGNTOOL_PATH, INSTALLER_CERT_WINDOWS_CER, CERT_PASSWORD, and CONTAINER_NAME environment variables were not provided.'
23+
);
24+
process.exit(1);
25+
}
26+
};

0 commit comments

Comments
 (0)