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: |
6262 null
6363 # Name of the secret that contains the certificate.
64- certificate-secret: WINDOWS_SIGNING_CERTIFICATE_PFX
64+ certificate-secret: INSTALLER_CERT_WINDOWS_CER
6565 # Name of the secret that contains the certificate password.
66- certificate-password-secret: WINDOWS_SIGNING_CERTIFICATE_PASSWORD
66+ 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).
7274 mergeable-channel-file: 'false'
75+ # as this runs on a self hosted runner, we need to avoid building with the default working directory path,
76+ # otherwise paths in the build job will be too long for `light.exe`
77+ # we use the below as a Symbolic link (just changing the wd will break the checkout action)
78+ # this is a work around (see: https://github.com/actions/checkout/issues/197).
79+ working-directory: 'C:\a'
7380 artifacts:
7481 - path: '*Windows_64bit.exe'
7582 name: Windows_X86-64_interactive_installer
@@ -270,6 +277,14 @@ jobs:
270277 env :
271278 # Location of artifacts generated by build.
272279 BUILD_ARTIFACTS_PATH : electron-app/dist/build-artifacts
280+ # to skip passing signing credentials to electron-builder
281+ IS_WINDOWS_CONFIG : ${{ matrix.config.name == 'Windows' }}
282+ INSTALLER_CERT_WINDOWS_CER : " /tmp/cert.cer"
283+ # We are hardcoding the path for signtool because is not present on the windows PATH env var by default.
284+ # Keep in mind that this path could change when upgrading to a new runner version
285+ SIGNTOOL_PATH : " C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x86/signtool.exe"
286+ WIN_CERT_PASSWORD : ${{ secrets.INSTALLER_CERT_WINDOWS_PASSWORD }}
287+ WIN_CERT_CONTAINER_NAME : ${{ secrets.INSTALLER_CERT_WINDOWS_CONTAINER }}
273288 strategy :
274289 matrix :
275290 config : ${{ fromJson(needs.select-targets.outputs.build-matrix) }}
@@ -283,6 +298,12 @@ jobs:
283298 timeout-minutes : 90
284299
285300 steps :
301+ - name : Symlink custom working directory
302+ shell : cmd
303+ if : runner.os == 'Windows' && matrix.config.working-directory
304+ run : |
305+ if not exist "${{ matrix.config.working-directory }}" mklink /d "${{ matrix.config.working-directory }}" "C:\actions-runner\_work\arduino-ide\arduino-ide"
306+
286307 - name : Checkout
287308 if : fromJSON(matrix.config.container) == null
288309 uses : actions/checkout@v4
@@ -293,42 +314,42 @@ jobs:
293314 uses : actions/checkout@v3
294315
295316 - name : Install Node.js
296- if : fromJSON(matrix.config.container) == null
317+ if : fromJSON(matrix.config.container) == null && runner.os != 'Windows'
297318 uses : actions/setup-node@v4
298319 with :
299320 node-version : ${{ env.NODE_VERSION }}
300321 registry-url : ' https://registry.npmjs.org'
301322 cache : ' yarn'
302323
303324 - name : Install Python 3.x
304- if : fromJSON(matrix.config.container) == null
325+ if : fromJSON(matrix.config.container) == null && runner.os != 'Windows'
305326 uses : actions/setup-python@v5
306327 with :
307328 python-version : ' 3.11.x'
308329
309330 - name : Install Go
310- if : fromJSON(matrix.config.container) == null
331+ if : fromJSON(matrix.config.container) == null && runner.os != 'Windows'
311332 uses : actions/setup-go@v5
312333 with :
313334 go-version : ${{ env.GO_VERSION }}
314335
315336 - name : Install Go
316337 # actions/setup-go@v5 has dependency on a higher version of glibc than available in the Linux container.
317- if : fromJSON(matrix.config.container) != null
338+ if : fromJSON(matrix.config.container) != null && runner.os != 'Windows'
318339 uses : actions/setup-go@v4
319340 with :
320341 go-version : ${{ env.GO_VERSION }}
321342
322343 - name : Install Taskfile
323- if : fromJSON(matrix.config.container) == null
344+ if : fromJSON(matrix.config.container) == null && runner.os != 'Windows'
324345 uses : arduino/setup-task@v2
325346 with :
326347 repo-token : ${{ secrets.GITHUB_TOKEN }}
327348 version : 3.x
328349
329350 - name : Install Taskfile
330351 # actions/setup-task@v2 has dependency on a higher version of glibc than available in the Linux container.
331- if : fromJSON(matrix.config.container) != null
352+ if : fromJSON(matrix.config.container) != null && runner.os != 'Windows'
332353 uses : arduino/setup-task@v1
333354 with :
334355 repo-token : ${{ secrets.GITHUB_TOKEN }}
@@ -350,9 +371,10 @@ jobs:
350371 CREATE_USERNAME : ${{ secrets.CREATE_USERNAME }}
351372 CREATE_PASSWORD : ${{ secrets.CREATE_PASSWORD }}
352373 CREATE_CLIENT_SECRET : ${{ secrets.CREATE_CLIENT_SECRET }}
374+ working-directory : ${{ runner.os == 'Windows' && matrix.config.working-directory || './' }}
353375 run : |
354376 # See: https://www.electron.build/code-signing
355- if [ $CAN_SIGN = false ]; then
377+ if [ $CAN_SIGN = false ] || [ $IS_WINDOWS_CONFIG = true ] ; then
356378 echo "Skipping the app signing: certificate not provided."
357379 else
358380 export CSC_LINK="${{ runner.temp }}/signing_certificate.${{ matrix.config.certificate-extension }}"
@@ -372,13 +394,14 @@ jobs:
372394 yarn --cwd electron-app rebuild
373395 yarn --cwd electron-app build
374396 yarn --cwd electron-app package
375-
397+
376398 # Both macOS jobs generate a "channel update info file" with same path and name. The second job to complete would
377399 # overwrite the file generated by the first in the workflow artifact.
378400 - name : Stage channel file for merge
379401 if : >
380402 needs.select-targets.outputs.merge-channel-files == 'true' &&
381403 matrix.config.mergeable-channel-file == 'true'
404+ working-directory : ${{ runner.os == 'Windows' && matrix.config.working-directory || './' }}
382405 run : |
383406 staged_channel_files_path="${{ runner.temp }}/staged-channel-files"
384407 mkdir "$staged_channel_files_path"
@@ -398,13 +421,21 @@ jobs:
398421 with :
399422 if-no-files-found : error
400423 name : ${{ env.STAGED_CHANNEL_FILES_ARTIFACT }}
401- path : ${{ env.STAGED_CHANNEL_FILES_PATH }}
424+ path : ${{ runner.os == 'Windows' && matrix.config.working-directory && format('{0}/{1}', matrix.config.working-directory, env.STAGED_CHANNEL_FILES_PATH) || env.STAGED_CHANNEL_FILES_PATH }}
425+
402426
403427 - name : Upload [GitHub Actions]
404428 uses : actions/upload-artifact@v3
405429 with :
406430 name : ${{ env.JOB_TRANSFER_ARTIFACT }}
407- path : ${{ env.BUILD_ARTIFACTS_PATH }}
431+ path : ${{ runner.os == 'Windows' && matrix.config.working-directory && format('{0}/{1}', matrix.config.working-directory, env.BUILD_ARTIFACTS_PATH) || env.BUILD_ARTIFACTS_PATH }}
432+
433+ - name : Manual Clean up for self-hosted runners
434+ if : runner.os == 'Windows' && matrix.config.working-directory
435+ shell : cmd
436+ run : |
437+ rmdir /s /q "${{ matrix.config.working-directory }}"
438+ rmdir /s /q "C:\actions-runner\_work\arduino-ide\arduino-ide"
408439
409440 merge-channel-files :
410441 needs :
0 commit comments