diff --git a/.github/workflows/build_executables.yaml b/.github/workflows/build_executables.yaml index a0a0e31..25fc594 100644 --- a/.github/workflows/build_executables.yaml +++ b/.github/workflows/build_executables.yaml @@ -47,14 +47,6 @@ jobs: - name: Install dependencies run: npm cache clean --force && npm install - - name: Resign native binaries with ad-hoc signature - if: matrix.os == 'macos-latest' - run: | - codesign --remove-signature resources/mac/qgenie-api || true - codesign --remove-signature resources/mac/qgenie-ai || true - codesign --sign - resources/mac/qgenie-api - codesign --sign - resources/mac/qgenie-ai - - name: Build the app run: npm run build -- --${{ matrix.os == 'macos-latest' && 'mac' || 'win' }} diff --git a/electron-builder.yml b/electron-builder.yml index 800c387..382f773 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -1,5 +1,6 @@ appId: com.Queryus.QGenie productName: QGenie +afterPack: ./scripts/afterPack.js extraResources: - from: 'resources/' to: 'resources' diff --git a/scripts/afterPack.js b/scripts/afterPack.js new file mode 100644 index 0000000..59d34f2 --- /dev/null +++ b/scripts/afterPack.js @@ -0,0 +1,42 @@ +// scripts/afterPack.js +import { execSync } from 'child_process' +import path from 'path' + +exports.default = async function (context) { + const { appOutDir, packager } = context + const appName = packager.appInfo.productFilename + + // macOS 빌드일 경우에만 실행 + if (process.platform !== 'darwin') { + return + } + + console.log('--- afterPack hook: Resigning native binaries ---') + + // 서명할 실행 파일들의 경로를 지정합니다. + const apiPath = path.join(appOutDir, `${appName}.app/Contents/Resources/resources/mac/qgenie-api`) + const aiPath = path.join(appOutDir, `${appName}.app/Contents/Resources/resources/mac/qgenie-ai`) + + const binaries = [apiPath, aiPath] + + for (const binaryPath of binaries) { + try { + console.log(`Removing existing signature from: ${binaryPath}`) + execSync(`codesign --remove-signature "${binaryPath}"`) + } catch (error) { + console.warn(`Could not remove signature from ${binaryPath}: ${error.message}`) + } + + try { + console.log(`Applying ad-hoc signature to: ${binaryPath}`) + // 애드혹 서명을 적용합니다. + execSync(`codesign --sign - "${binaryPath}"`) + console.log(`Successfully signed: ${binaryPath}`) + } catch (error) { + console.error(`Failed to sign ${binaryPath}: ${error.message}`) + throw error // 서명 실패 시 빌드를 중단 + } + } + + console.log('--- Finished resigning native binaries ---') +}