Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9c99895

Browse files
committedJun 29, 2024·
attempt sign of all windows files
1 parent b1607cd commit 9c99895

File tree

2 files changed

+54
-29
lines changed

2 files changed

+54
-29
lines changed
 

‎.github/workflows/build.yml

+53-28
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,16 @@ env:
7575
artifacts:
7676
- path: '*Windows_64bit.exe'
7777
name: Windows_X86-64_interactive_installer
78-
- path: '*Windows_64bit_signed.exe'
79-
name: Windows_X86-64_interactive_installer_signed
78+
- path: '*Windows_64bit_unsigned.exe'
79+
name: Windows_X86-64_interactive_installer_unsigned
8080
- path: '*Windows_64bit.msi'
8181
name: Windows_X86-64_MSI
82+
- path: '*Windows_64bit_unsigned.msi'
83+
name: Windows_X86-64_MSI_unsigned
8284
- path: '*Windows_64bit.zip'
8385
name: Windows_X86-64_zip
86+
- path: '*Windows_64bit_unsigned.zip'
87+
name: Windows_X86-64_zip_unsigned
8488
- config:
8589
name: Linux
8690
runs-on: ubuntu-latest
@@ -433,38 +437,59 @@ jobs:
433437
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
434438
path: ${{ env.BUILD_ARTIFACTS_PATH }}
435439

436-
- name: Save artifact path to variable
440+
- name: Find and process artifacts
437441
shell: bash
438442
run: |
439-
ARTIFACT=$(find "${{ env.BUILD_ARTIFACTS_PATH }}" -name "*Windows_64bit.exe" | head -n 1)
440-
# Convert to Windows-style path with forward slashes
441-
FULL_PATH=$(cygpath -w $ARTIFACT | sed 's|\\|/|g')
442-
echo "ARTIFACT_PATH=$FULL_PATH" >> $GITHUB_ENV
443+
shopt -s nullglob
444+
for ARTIFACT in "${{ env.BUILD_ARTIFACTS_PATH }}"/*_unsigned.{exe,zip,msi}; do
445+
echo "Processing $ARTIFACT"
446+
FILENAME=$(basename "$ARTIFACT")
447+
BASE_NAME="${FILENAME%.*}"
448+
EXTENSION="${FILENAME##*.}"
449+
# Remove '_unsigned' from the base name
450+
SIGNED_BASE_NAME="${BASE_NAME%_unsigned}"
451+
452+
# Sign and rename EXE and MSI files
453+
if [[ "$EXTENSION" == "exe" || "$EXTENSION" == "msi" ]]; then
454+
echo "Signing $ARTIFACT"
455+
"${{ 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"
456+
SIGNED_ARTIFACT_PATH="${{ env.BUILD_ARTIFACTS_PATH }}/${SIGNED_BASE_NAME}.${EXTENSION}"
457+
mv "$ARTIFACT" "$SIGNED_ARTIFACT_PATH"
458+
echo "Renamed $ARTIFACT to $SIGNED_ARTIFACT_PATH"
459+
fi
460+
461+
# Unzip, Sign, and Rezip ZIP file without '_unsigned' in the name
462+
if [[ "$EXTENSION" == "zip" ]]; then
463+
TEMP_DIR=$(mktemp -d)
464+
unzip "$ARTIFACT" -d "$TEMP_DIR"
465+
find "$TEMP_DIR" -type f -name '*.exe' -exec "${{ 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 {} \;
466+
SIGNED_ARTIFACT_PATH="${{ env.BUILD_ARTIFACTS_PATH }}/${SIGNED_BASE_NAME}.${EXTENSION}"
467+
pushd "$TEMP_DIR"
468+
zip -r "$SIGNED_ARTIFACT_PATH" .
469+
popd
470+
rm -rf "$TEMP_DIR"
471+
echo "Processed and re-zipped $ARTIFACT"
472+
fi
473+
done
443474
444-
- name: Save Win signing certificate to file
445-
run: echo "${{ secrets.INSTALLER_CERT_WINDOWS_CER }}" | base64 --decode > ${{ env.INSTALLER_CERT_WINDOWS_CER }}
475+
- name: Upload signed EXE
476+
uses: actions/upload-artifact@v3
477+
with:
478+
name: Windows_X86-64_interactive_installer
479+
path: ${{ env.BUILD_ARTIFACTS_PATH }}/*Windows_64bit.exe
446480

447-
- name: Sign EXE
448-
env:
449-
CERT_PASSWORD: ${{ secrets.INSTALLER_CERT_WINDOWS_PASSWORD }}
450-
CONTAINER_NAME: ${{ secrets.INSTALLER_CERT_WINDOWS_CONTAINER }}
451-
# https://stackoverflow.com/questions/17927895/automate-extended-validation-ev-code-signing-with-safenet-etoken
452-
run: |
453-
"${{ 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 ${{ env.ARTIFACT_PATH }}
454-
455-
- name: Rename signed EXE
456-
shell: bash
457-
run: |
458-
BASE_NAME=$(echo "${{ env.ARTIFACT_PATH }}" | sed 's/.exe$//')
459-
SIGNED_EXE_PATH="${BASE_NAME}_signed.exe"
460-
mv "${{ env.ARTIFACT_PATH }}" "$SIGNED_EXE_PATH"
461-
echo "SIGNED_ARTIFACT_PATH=$SIGNED_EXE_PATH" >> $GITHUB_ENV
462-
463-
- name: Upload artifacts with signed EXE
481+
- name: Upload signed MSI
464482
uses: actions/upload-artifact@v3
465483
with:
466-
name: Windows_X86-64_interactive_installer_signed
467-
path: ${{ env.SIGNED_ARTIFACT_PATH }}
484+
name: Windows_X86-64_MSI
485+
path: ${{ env.BUILD_ARTIFACTS_PATH }}/*Windows_64bit.msi
486+
487+
488+
- name: Upload signed ZIP
489+
uses: actions/upload-artifact@v3
490+
with:
491+
name: Windows_X86-64_zip
492+
path: ${{ env.BUILD_ARTIFACTS_PATH }}/*Windows_64bit.zip
468493

469494
# This step is needed because the self hosted runner does not delete files automatically
470495
- name: Clean up artifacts

‎electron-app/scripts/package.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ async function getArtifactName(version) {
100100
switch (platform) {
101101
case 'win32': {
102102
if (arch === 'x64') {
103-
return `${name}_${version}_Windows_64bit.\$\{ext}`;
103+
return `${name}_${version}_Windows_64bit_unsigned.\$\{ext}`;
104104
}
105105
throw new Error(`Unsupported platform, arch: ${platform}, ${arch}`);
106106
}

0 commit comments

Comments
 (0)
Please sign in to comment.