Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
"mac": {
"category": "public.app-category.developer-tools",
"darkModeSupport": true,
"identity": "",
"target": [
{
"target": "zip",
Expand Down
49 changes: 49 additions & 0 deletions src-script/build-release-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,50 @@ const fs = require('fs')
const yargs = require('yargs/yargs')
const { hideBin } = require('yargs/helpers')

/**
* Remove adhoc signatures from a macOS zip package.
* Unzips, strips signatures, and re-zips.
* @param {string} zipPath - Path to the zip file
*/
async function removeAdhocSignature(zipPath) {
const absZipPath = path.resolve(zipPath)
const tempDir = absZipPath.replace('.zip', '-unsigned')
const zipName = path.basename(zipPath)

console.log(`Removing adhoc signatures from ${zipName}...`)

// Unzip
await scriptUtil.executeCmd({}, 'unzip', ['-q', absZipPath, '-d', tempDir])

// Find and remove signature from main app
const appPath = path.join(tempDir, 'zap.app')
if (fs.existsSync(appPath)) {
await scriptUtil.executeCmd({}, 'codesign', ['--remove-signature', appPath])

// Remove signatures from nested frameworks and binaries
try {
await scriptUtil.executeCmd({}, 'sh', [
'-c',
`find "${appPath}" -type f -perm +111 -exec codesign --remove-signature {} \\; 2>/dev/null || true`
])
} catch (e) {
// Ignore errors from codesign on files that aren't signed
}
}

// Remove old zip and create new one from within the temp directory
fs.unlinkSync(absZipPath)
await scriptUtil.executeCmd({}, 'sh', [
'-c',
`cd "${tempDir}" && zip -r -q "${absZipPath}" .`
])

// Cleanup temp directory
fs.rmSync(tempDir, { recursive: true, force: true })

console.log(`Successfully removed signatures from ${zipName}`)
}

/**
*
* @param {*} osName
Expand All @@ -35,6 +79,11 @@ async function buildForOS(osName, outputPath) {
await scriptUtil.executeCmd({}, 'npm', ['run', 'pack:mac']) // Building electron app
await scriptUtil.executeCmd({}, 'npm', ['run', 'pkg:mac']) // Building zap-cli
await scriptUtil.executeCmd({}, 'npm', ['run', 'pack:cli:mac']) // Adding zap-cli to zip file

// Remove adhoc signatures from macOS packages
await removeAdhocSignature('./dist/zap-mac-x64.zip')
await removeAdhocSignature('./dist/zap-mac-arm64.zip')

if (outputPath) {
await scriptUtil.executeCmd({}, 'mv', [
'./dist/zap-mac-x64.zip',
Expand Down
Loading