4545      run :
4646        shell : bash 
4747
48- #  by default disable CGO, it's not needed (except on macos)
48+      #  by default disable CGO, it's not needed (except on macos)
4949    env :
5050      CGO_ENABLED : 0 
5151
@@ -157,7 +157,7 @@ jobs:
157157  create-macos-bundle :
158158    needs : build 
159159
160-     #  for not  they are exaclty the same
160+     #  for now  they are exaclty the same
161161    strategy :
162162      matrix :
163163        arch : [amd64, arm64] 
@@ -371,9 +371,6 @@ jobs:
371371      #  vars used by installbuilder
372372      INSTALLBUILDER_PATH : " /opt/installbuilder-23.11.0/bin/builder" 
373373      INSTALLER_VARS : " project.outputDirectory=$PWD project.version=${GITHUB_REF##*/} workspace=$PWD realname=Arduino_Create_Agent" 
374-       #  installbuilder will read this vars automatically (defined in installer.xml):
375-       INSTALLER_CERT_WINDOWS_PASSWORD : ${{ secrets.INSTALLER_CERT_WINDOWS_PASSWORD }} 
376-       INSTALLER_CERT_WINDOWS_PFX : " /tmp/ArduinoCerts2020.pfx" 
377374
378375    strategy :
379376      fail-fast : false  #  if one os is failing continue nonetheless
@@ -424,11 +421,6 @@ jobs:
424421      - name : Save InstallBuilder license to file 
425422        run : echo "${{ secrets.INSTALLER_LICENSE }}" > /tmp/license.xml 
426423
427-       - name : Save Win signing certificate to file 
428-         run : echo "${{ secrets.INSTALLER_CERT_WINDOWS_PFX }}" | base64 --decode > ${{ env.INSTALLER_CERT_WINDOWS_PFX}} 
429-         if : matrix.os == 'windows-2019' 
430- 
431-         #  installbuilder reads the env vars with certs paths and use it to sign the installer.
432424      - name : Launch Bitrock installbuilder 
433425        run : ${{ env.INSTALLBUILDER_PATH }} build installer.xml ${{ matrix.installbuilder-name }} --verbose --license /tmp/license.xml  --setvars ${{ env.INSTALLER_VARS }} architecture=${{ matrix.arch }} 
434426
@@ -443,6 +435,49 @@ jobs:
443435          path : ArduinoCreateAgent* 
444436          if-no-files-found : error 
445437
438+   #  This job will sign the Windows installer
439+   sign-windows :
440+     runs-on : [self-hosted, windows-sign-pc] 
441+     needs : package 
442+ 
443+     defaults :
444+       run :
445+         shell : bash 
446+ 
447+     env :
448+       INSTALLER_CERT_WINDOWS_CER : " /tmp/cert.cer" 
449+       #  We are hardcoding the path for signtool because is not present on the windows PATH env var by default.
450+       #  Keep in mind that this path could change when upgrading to a new runner version
451+       SIGNTOOL_PATH : " C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x86/signtool.exe" 
452+     
453+     strategy :
454+       matrix :
455+         arch : [amd64, 386] 
456+     
457+     steps :
458+       - name : Download artifact 
459+         uses : actions/download-artifact@v3 
460+         with :
461+           name : ArduinoCreateAgent-windows-${{ matrix.arch }} 
462+       
463+       - name : Save Win signing certificate to file 
464+         run : echo "${{ secrets.INSTALLER_CERT_WINDOWS_CER }}" | base64 --decode > ${{ env.INSTALLER_CERT_WINDOWS_CER}} 
465+ 
466+       - name : Sign EXE 
467+         env :
468+           CERT_PASSWORD : ${{ secrets.INSTALLER_CERT_WINDOWS_PASSWORD }} 
469+           CONTAINER_NAME : ${{ secrets.INSTALLER_CERT_WINDOWS_CONTAINER }} 
470+           #  https://stackoverflow.com/questions/17927895/automate-extended-validation-ev-code-signing-with-safenet-etoken
471+         run : |  
472+           "${{ env.SIGNTOOL_PATH }}" sign -d "Arduino Create Agent" -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 "ArduinoCreateAgent-${GITHUB_REF##*/}-windows-${{ matrix.arch }}-installer.exe" 
473+ 
474+ name : Upload artifacts 
475+         uses : actions/upload-artifact@v3 
476+         with :
477+           if-no-files-found : error 
478+           name : ArduinoCreateAgent-windows-${{ matrix.arch }}-signed 
479+           path : ArduinoCreateAgent-*-windows-${{ matrix.arch }}-installer.exe 
480+ 
446481  #  This job will generate a dmg mac installer, sign/notarize it.
447482  generate-sign-dmg :
448483    needs : notarize-macos 
@@ -544,7 +579,7 @@ jobs:
544579  create-release :
545580    runs-on : ubuntu-20.04 
546581    environment : production 
547-     needs : [build, package,  generate-sign-dmg] 
582+     needs : [build, generate-sign-dmg, sign-windows ] 
548583
549584    steps :
550585      - name : Checkout 
@@ -563,7 +598,7 @@ jobs:
563598          mv -v ArduinoCreateAgent-linux-amd64/* release/ 
564599          cat ArduinoCreateAgent-osx-amd64/*.tar | tar -xvf - -i -C release/ 
565600          rm -v release/._ArduinoCreateAgent*.dmg 
566-           mv -v ArduinoCreateAgent-windows*/* release/ 
601+           mv -v ArduinoCreateAgent-windows*-signed /* release/ 
567602
568603name : VirusTotal Scan 
569604        id : virustotal_step 
0 commit comments