feat(electron-forge): clear signing logs on failure

This commit is contained in:
Elian Doran 2026-03-01 20:02:08 +02:00
parent 420f0917be
commit e1ad48b42a
No known key found for this signature in database
2 changed files with 14 additions and 6 deletions

View File

@ -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 }}

View File

@ -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.`);