diff --git a/Jenkinsfile b/Jenkinsfile index d2ae475..624b963 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -90,9 +90,6 @@ def prepareMacBuildWorkspace() { if (isUnix()) { sh ''' df -h . - if ! command -v create-dmg >/dev/null 2>&1; then - brew install create-dmg - fi for vol in /Volumes/Farm\\ Control\\ Server*; do if [ -d "$vol" ]; then hdiutil detach "$vol" -force || true diff --git a/scripts/finalize-desktop-artifacts.mjs b/scripts/finalize-desktop-artifacts.mjs index c1efe92..c0f196a 100644 --- a/scripts/finalize-desktop-artifacts.mjs +++ b/scripts/finalize-desktop-artifacts.mjs @@ -185,46 +185,14 @@ function cleanStagingArtifacts(keepNames) { } } -function findCreateDmgCommand() { - const which = spawnSync("which", ["create-dmg"], { encoding: "utf8" }); - if (which.status === 0 && which.stdout.trim()) { - return which.stdout.trim(); - } - - for (const candidate of [ - "/opt/homebrew/bin/create-dmg", - "/usr/local/bin/create-dmg", - ]) { - if (existsSync(candidate)) { - return candidate; - } - } - - return null; -} - -function buildMacDmg(appBundlePath, arch) { - const createDmg = findCreateDmgCommand(); - if (!createDmg) { - throw new Error( - "create-dmg not found. Install with: brew install create-dmg", - ); - } - - const dmgPath = path.join( - artifactDir, - getReleaseArtifactName(version, arch, "dmg"), - ); - - mkdirSync(artifactDir, { recursive: true }); - - const stagingDir = path.join( - path.dirname(appBundlePath), - ".finalize-dmg-staging", - ); - rmSync(stagingDir, { recursive: true, force: true }); - mkdirSync(stagingDir, { recursive: true }); +const CREATE_DMG_PATH = "/usr/local/bin/create-dmg"; +function buildMacDmgWithCreateDmg( + createDmg, + appBundlePath, + dmgPath, + stagingDir, +) { const appName = path.basename(appBundlePath); symlinkSync(appBundlePath, path.join(stagingDir, appName), "dir"); @@ -246,8 +214,6 @@ function buildMacDmg(appBundlePath, arch) { { stdio: "inherit" }, ); - rmSync(stagingDir, { recursive: true, force: true }); - if (result.status !== 0) { throw new Error(`create-dmg failed with exit code ${result.status ?? 1}`); } @@ -256,10 +222,45 @@ function buildMacDmg(appBundlePath, arch) { throw new Error(`create-dmg did not produce ${dmgPath}`); } - console.log(`Published ${dmgPath}`); return dmgPath; } +function buildMacDmg(appBundlePath, arch) { + if (!existsSync(CREATE_DMG_PATH)) { + throw new Error(`create-dmg not found at ${CREATE_DMG_PATH}`); + } + + const dmgPath = path.join( + artifactDir, + getReleaseArtifactName(version, arch, "dmg"), + ); + + mkdirSync(artifactDir, { recursive: true }); + + const stagingDir = path.join( + path.dirname(appBundlePath), + ".finalize-dmg-staging", + ); + rmSync(stagingDir, { recursive: true, force: true }); + mkdirSync(stagingDir, { recursive: true }); + + let builtDmgPath; + + try { + builtDmgPath = buildMacDmgWithCreateDmg( + CREATE_DMG_PATH, + appBundlePath, + dmgPath, + stagingDir, + ); + } finally { + rmSync(stagingDir, { recursive: true, force: true }); + } + + console.log(`Published ${builtDmgPath}`); + return builtDmgPath; +} + function cleanMacBuildDir(arch) { const platformDir = path.join(getBuildRoot(), `stable-macos-${arch}`); if (existsSync(platformDir)) {