diff --git a/.github/actions/build-electron/action.yml b/.github/actions/build-electron/action.yml index 283b9c384f..58fa9743a5 100644 --- a/.github/actions/build-electron/action.yml +++ b/.github/actions/build-electron/action.yml @@ -72,11 +72,6 @@ runs: FLATPAK_VERSION='24.08' flatpak install --user --no-deps --arch $FLATPAK_ARCH --assumeyes runtime/org.freedesktop.Platform/$FLATPAK_ARCH/$FLATPAK_VERSION runtime/org.freedesktop.Sdk/$FLATPAK_ARCH/$FLATPAK_VERSION org.electronjs.Electron2.BaseApp/$FLATPAK_ARCH/$FLATPAK_VERSION - - name: Unblock signing - if: ${{ inputs.os == 'windows' }} - shell: ${{ inputs.shell }} - run: del ${{ env.WINDOWS_SIGN_ERROR_LOG }} - - name: Update build info shell: ${{ inputs.shell }} run: pnpm run chore:update-build-info @@ -90,6 +85,7 @@ runs: APPLE_ID: ${{ env.APPLE_ID }} APPLE_ID_PASSWORD: ${{ env.APPLE_ID_PASSWORD }} WINDOWS_SIGN_EXECUTABLE: ${{ env.WINDOWS_SIGN_EXECUTABLE }} + WINDOWS_SIGN_ERROR_LOG: ${{ env.WINDOWS_SIGN_ERROR_LOG }} TRILIUM_ARTIFACT_NAME_HINT: TriliumNotes-${{ github.ref_name }}-${{ inputs.os }}-${{ inputs.arch }} TARGET_ARCH: ${{ inputs.arch }} run: pnpm run --filter desktop electron-forge:make --arch=${{ inputs.arch }} --platform=${{ inputs.forge_platform }} diff --git a/apps/desktop/electron-forge/sign-windows.cjs b/apps/desktop/electron-forge/sign-windows.cjs index 54e852f36b..b54b8e7776 100644 --- a/apps/desktop/electron-forge/sign-windows.cjs +++ b/apps/desktop/electron-forge/sign-windows.cjs @@ -1,9 +1,10 @@ const child_process = require("child_proces"); const fs = require("fs"); +const { rm } = require("fs/promises"); const path = require("path"); module.exports = async function (filePath) { - const { WINDOWS_SIGN_EXECUTABLE } = process.env; + const { WINDOWS_SIGN_EXECUTABLE, WINDOWS_SIGN_ERROR_LOG } = process.env; if (!WINDOWS_SIGN_EXECUTABLE) { console.warn("[Sign] Skip signing due to missing environment variable."); @@ -22,6 +23,17 @@ module.exports = async function (filePath) { let remainingTries = 10; let sleepTime = 10_000; while (remainingTries > 0) { + // Delete the log file that might be blocking the signing. + try { + await rm(WINDOWS_SIGN_ERROR_LOG, { + force: true + }) + } catch (e) { + console.error("[Sign] Unable to delete the log file."); + process.exit(2); + } + + // Run the signing. try { child_process.execSync(command); console.log(`[Sign] Signed ${filePath} successfully.`);