Compare commits
No commits in common. "8b8475d11dc6083a38a7b933e761749b12416d42" and "6ed23472147d8b435f394dc50613383070daee22" have entirely different histories.
8b8475d11d
...
6ed2347214
@ -14,7 +14,7 @@
|
|||||||
"build:server": "bun run scripts/build-server.mjs",
|
"build:server": "bun run scripts/build-server.mjs",
|
||||||
"build:renderer": "vite build src/app",
|
"build:renderer": "vite build src/app",
|
||||||
"build:app": "bun run build && electrobun build --env=stable",
|
"build:app": "bun run build && electrobun build --env=stable",
|
||||||
"build:app:mac": "bun scripts/build-macos.mjs",
|
"build:app:mac": "bun run build && electrobun build --env=stable",
|
||||||
"build:linux": "bun run cleanBuild && bun run build:server && bun run build:linux-binary && bun run build:linux-packages",
|
"build:linux": "bun run cleanBuild && bun run build:server && bun run build:linux-binary && bun run build:linux-packages",
|
||||||
"build:linux-binary": "bun scripts/build-linux-binary.mjs",
|
"build:linux-binary": "bun scripts/build-linux-binary.mjs",
|
||||||
"build:linux-packages": "bash scripts/build-linux-packages.sh",
|
"build:linux-packages": "bash scripts/build-linux-packages.sh",
|
||||||
|
|||||||
@ -26,8 +26,6 @@
|
|||||||
<DirectoryRef Id="INSTALLFOLDER">
|
<DirectoryRef Id="INSTALLFOLDER">
|
||||||
<Component Id="SetupComponent" Guid="*">
|
<Component Id="SetupComponent" Guid="*">
|
||||||
<File Id="SetupExe" Source="$(var.SetupExe)" KeyPath="yes" />
|
<File Id="SetupExe" Source="$(var.SetupExe)" KeyPath="yes" />
|
||||||
<File Id="SetupArchive" Source="$(var.SetupArchive)" />
|
|
||||||
<File Id="SetupMetadata" Source="$(var.SetupMetadata)" />
|
|
||||||
</Component>
|
</Component>
|
||||||
</DirectoryRef>
|
</DirectoryRef>
|
||||||
|
|
||||||
|
|||||||
@ -1,53 +0,0 @@
|
|||||||
import { spawnSync } from "node:child_process";
|
|
||||||
import { fileURLToPath } from "node:url";
|
|
||||||
import path from "node:path";
|
|
||||||
|
|
||||||
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
||||||
const hostArch = process.arch === "arm64" ? "arm64" : "x64";
|
|
||||||
const targetArchs = ["arm64", "x64"];
|
|
||||||
|
|
||||||
function run(command, args, options = {}) {
|
|
||||||
const result = spawnSync(command, args, {
|
|
||||||
cwd: rootDir,
|
|
||||||
stdio: "inherit",
|
|
||||||
env: process.env,
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (result.status !== 0) {
|
|
||||||
process.exit(result.status ?? 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getElectrobunCommand(targetArch) {
|
|
||||||
const electrobunArgs = ["electrobun", "build", "--env=stable"];
|
|
||||||
|
|
||||||
if (targetArch === hostArch) {
|
|
||||||
return { command: "bun", args: electrobunArgs };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hostArch === "arm64" && targetArch === "x64") {
|
|
||||||
return { command: "arch", args: ["-x86_64", "bun", ...electrobunArgs] };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hostArch === "x64" && targetArch === "arm64") {
|
|
||||||
return { command: "arch", args: ["-arm64", "bun", ...electrobunArgs] };
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
run("bun", ["run", "build"]);
|
|
||||||
|
|
||||||
for (const targetArch of targetArchs) {
|
|
||||||
const invocation = getElectrobunCommand(targetArch);
|
|
||||||
if (!invocation) {
|
|
||||||
console.warn(
|
|
||||||
`Skipping macOS ${targetArch} build: unsupported cross-compile from ${hostArch}.`,
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`\n=== Building macOS ${targetArch} ===\n`);
|
|
||||||
run(invocation.command, invocation.args);
|
|
||||||
}
|
|
||||||
@ -2,12 +2,6 @@ param(
|
|||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$SetupExe,
|
[string]$SetupExe,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$SetupArchive,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$SetupMetadata,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$OutputMsi,
|
[string]$OutputMsi,
|
||||||
|
|
||||||
@ -40,14 +34,6 @@ function Find-WixTool($toolName) {
|
|||||||
throw "Could not find $toolName. Install WiX Toolset v3.11 or v3.14 on the Windows build agent."
|
throw "Could not find $toolName. Install WiX Toolset v3.11 or v3.14 on the Windows build agent."
|
||||||
}
|
}
|
||||||
|
|
||||||
function ConvertTo-WixVersion([string]$rawVersion) {
|
|
||||||
$parts = $rawVersion.Split('.')
|
|
||||||
while ($parts.Count -lt 4) {
|
|
||||||
$parts += '0'
|
|
||||||
}
|
|
||||||
return ($parts[0..3] -join '.')
|
|
||||||
}
|
|
||||||
|
|
||||||
$rootDir = Split-Path -Parent $PSScriptRoot
|
$rootDir = Split-Path -Parent $PSScriptRoot
|
||||||
$wxsPath = Join-Path $rootDir "packaging/windows/farmcontrol-server.wxs"
|
$wxsPath = Join-Path $rootDir "packaging/windows/farmcontrol-server.wxs"
|
||||||
$workDir = Join-Path $env:TEMP "farmcontrol-server-msi"
|
$workDir = Join-Path $env:TEMP "farmcontrol-server-msi"
|
||||||
@ -58,22 +44,28 @@ if (Test-Path $workDir) {
|
|||||||
}
|
}
|
||||||
New-Item -ItemType Directory -Path $workDir | Out-Null
|
New-Item -ItemType Directory -Path $workDir | Out-Null
|
||||||
|
|
||||||
|
function ConvertTo-WixVersion([string]$rawVersion) {
|
||||||
|
$parts = $rawVersion.Split('.')
|
||||||
|
while ($parts.Count -lt 4) {
|
||||||
|
$parts += '0'
|
||||||
|
}
|
||||||
|
return ($parts[0..3] -join '.')
|
||||||
|
}
|
||||||
|
|
||||||
$candle = Find-WixTool "candle"
|
$candle = Find-WixTool "candle"
|
||||||
$light = Find-WixTool "light"
|
$light = Find-WixTool "light"
|
||||||
|
|
||||||
$wixVersion = ConvertTo-WixVersion $Version
|
$wixVersion = ConvertTo-WixVersion $Version
|
||||||
$setupExePath = (Resolve-Path -LiteralPath $SetupExe).Path
|
$setupExePath = (Resolve-Path -LiteralPath $SetupExe).Path
|
||||||
$setupArchivePath = (Resolve-Path -LiteralPath $SetupArchive).Path
|
|
||||||
$setupMetadataPath = (Resolve-Path -LiteralPath $SetupMetadata).Path
|
|
||||||
|
|
||||||
|
# Quote -d defines so PowerShell passes them as single args to candle.exe.
|
||||||
|
# Unquoted -dVersion=$Version is parsed incorrectly; paths with spaces also break.
|
||||||
$candleArgs = @(
|
$candleArgs = @(
|
||||||
'-nologo'
|
'-nologo'
|
||||||
'-out'
|
'-out'
|
||||||
$wixObj
|
$wixObj
|
||||||
"-dVersion=$wixVersion"
|
"-dVersion=$wixVersion"
|
||||||
"-dSetupExe=$setupExePath"
|
"-dSetupExe=$setupExePath"
|
||||||
"-dSetupArchive=$setupArchivePath"
|
|
||||||
"-dSetupMetadata=$setupMetadataPath"
|
|
||||||
$wxsPath
|
$wxsPath
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,6 @@ const packageJson = JSON.parse(
|
|||||||
const version = getReleaseVersion(packageJson);
|
const version = getReleaseVersion(packageJson);
|
||||||
const artifactDir = path.join(rootDir, "app_dist");
|
const artifactDir = path.join(rootDir, "app_dist");
|
||||||
const identifier = "com.tombutcher.farmcontrolserver";
|
const identifier = "com.tombutcher.farmcontrolserver";
|
||||||
const artifactPrefix = `farmcontrol-server-${version}-`;
|
|
||||||
|
|
||||||
function walkFiles(dir) {
|
function walkFiles(dir) {
|
||||||
const files = [];
|
const files = [];
|
||||||
@ -50,43 +49,29 @@ function findByExtension(root, extension) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function findMacAppBundle(arch) {
|
function findMacAppBundle() {
|
||||||
const platformDir = path.join(rootDir, "build", `stable-macos-${arch}`);
|
const buildDir = path.join(rootDir, "build");
|
||||||
if (!existsSync(platformDir)) {
|
if (!existsSync(buildDir)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const entry of readdirSync(buildDir)) {
|
||||||
|
if (!entry.startsWith("stable-macos-")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const platformDir = path.join(buildDir, entry);
|
||||||
for (const child of readdirSync(platformDir)) {
|
for (const child of readdirSync(platformDir)) {
|
||||||
if (child.endsWith(".app")) {
|
if (child.endsWith(".app")) {
|
||||||
return path.join(platformDir, child);
|
return path.join(platformDir, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function findMacDmgSource(arch) {
|
function findWindowsSetupExe() {
|
||||||
const prefixedArtifact = walkFiles(artifactDir).find(
|
|
||||||
(filePath) =>
|
|
||||||
filePath.includes(`stable-macos-${arch}`) &&
|
|
||||||
filePath.toLowerCase().endsWith(".dmg"),
|
|
||||||
);
|
|
||||||
if (prefixedArtifact) {
|
|
||||||
return prefixedArtifact;
|
|
||||||
}
|
|
||||||
|
|
||||||
const buildDmg = findByExtension(
|
|
||||||
path.join(rootDir, "build", `stable-macos-${arch}`),
|
|
||||||
".dmg",
|
|
||||||
);
|
|
||||||
if (buildDmg) {
|
|
||||||
return buildDmg;
|
|
||||||
}
|
|
||||||
|
|
||||||
return findByExtension(artifactDir, ".dmg");
|
|
||||||
}
|
|
||||||
|
|
||||||
function findWindowsInstallerFiles() {
|
|
||||||
const buildDir = path.join(rootDir, "build");
|
const buildDir = path.join(rootDir, "build");
|
||||||
if (!existsSync(buildDir)) {
|
if (!existsSync(buildDir)) {
|
||||||
return null;
|
return null;
|
||||||
@ -98,33 +83,20 @@ function findWindowsInstallerFiles() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const platformDir = path.join(buildDir, entry);
|
const platformDir = path.join(buildDir, entry);
|
||||||
const files = walkFiles(platformDir);
|
const setupExe = walkFiles(platformDir).find((filePath) =>
|
||||||
const setupExe = files.find((filePath) =>
|
filePath.toLowerCase().endsWith("-setup.exe"),
|
||||||
/-setup\.exe$/i.test(filePath),
|
|
||||||
);
|
);
|
||||||
const setupArchive = files.find((filePath) =>
|
if (setupExe) {
|
||||||
/-setup\.tar\.zst$/i.test(filePath),
|
return setupExe;
|
||||||
);
|
|
||||||
const setupMetadata = files.find((filePath) =>
|
|
||||||
/-setup\.metadata\.json$/i.test(filePath),
|
|
||||||
);
|
|
||||||
const setupZip = files.find((filePath) =>
|
|
||||||
/-setup\.zip$/i.test(filePath),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (setupExe && setupArchive && setupMetadata) {
|
|
||||||
return { setupExe, setupArchive, setupMetadata, setupZip };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return findByExtension(buildDir, "-Setup.exe");
|
||||||
}
|
}
|
||||||
|
|
||||||
function publishArtifact(sourcePath, arch, ext) {
|
function publishArtifact(sourcePath, arch, ext) {
|
||||||
if (!sourcePath || !existsSync(sourcePath)) {
|
if (!sourcePath || !existsSync(sourcePath)) {
|
||||||
throw new Error(
|
throw new Error(`Missing source artifact for ${arch}.${ext}: ${sourcePath ?? "not found"}`);
|
||||||
`Missing source artifact for ${arch}.${ext}: ${sourcePath ?? "not found"}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdirSync(artifactDir, { recursive: true });
|
mkdirSync(artifactDir, { recursive: true });
|
||||||
@ -137,25 +109,18 @@ function publishArtifact(sourcePath, arch, ext) {
|
|||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanStagingArtifacts(keepNames) {
|
function cleanArtifactDir(keepNames) {
|
||||||
if (!existsSync(artifactDir)) {
|
if (!existsSync(artifactDir)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const entry of readdirSync(artifactDir)) {
|
for (const entry of readdirSync(artifactDir)) {
|
||||||
if (keepNames.includes(entry) || entry.startsWith(artifactPrefix)) {
|
if (keepNames.includes(entry)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
entry.includes("stable-macos-") ||
|
|
||||||
entry.includes("stable-win-") ||
|
|
||||||
entry.endsWith("-update.json") ||
|
|
||||||
entry.endsWith(".tar.gz")
|
|
||||||
) {
|
|
||||||
rmSync(path.join(artifactDir, entry), { recursive: true, force: true });
|
rmSync(path.join(artifactDir, entry), { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildMacPkg(appBundlePath, arch) {
|
function buildMacPkg(appBundlePath, arch) {
|
||||||
@ -188,7 +153,7 @@ function buildMacPkg(appBundlePath, arch) {
|
|||||||
return pkgPath;
|
return pkgPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildWindowsMsi(installerFiles, arch) {
|
function buildWindowsMsi(setupExePath, arch) {
|
||||||
const scriptPath = path.join(rootDir, "scripts/build-windows-msi.ps1");
|
const scriptPath = path.join(rootDir, "scripts/build-windows-msi.ps1");
|
||||||
const msiPath = path.join(
|
const msiPath = path.join(
|
||||||
artifactDir,
|
artifactDir,
|
||||||
@ -214,11 +179,7 @@ function buildWindowsMsi(installerFiles, arch) {
|
|||||||
"-File",
|
"-File",
|
||||||
scriptPath,
|
scriptPath,
|
||||||
"-SetupExe",
|
"-SetupExe",
|
||||||
installerFiles.setupExe,
|
setupExePath,
|
||||||
"-SetupArchive",
|
|
||||||
installerFiles.setupArchive,
|
|
||||||
"-SetupMetadata",
|
|
||||||
installerFiles.setupMetadata,
|
|
||||||
"-OutputMsi",
|
"-OutputMsi",
|
||||||
msiPath,
|
msiPath,
|
||||||
"-Version",
|
"-Version",
|
||||||
@ -235,44 +196,36 @@ function buildWindowsMsi(installerFiles, arch) {
|
|||||||
return msiPath;
|
return msiPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.platform === "darwin") {
|
const published = [];
|
||||||
const buildArch = getReleaseArch(
|
|
||||||
process.env.ELECTROBUN_ARCH || process.arch,
|
|
||||||
);
|
|
||||||
const dmgSource = findMacDmgSource(buildArch);
|
|
||||||
const appBundle = findMacAppBundle(buildArch);
|
|
||||||
|
|
||||||
if (!dmgSource || !appBundle) {
|
if (process.platform === "darwin") {
|
||||||
console.log(
|
const arch = getReleaseArch();
|
||||||
`finalize-desktop-artifacts: no macOS ${buildArch} release artifacts found, skipping`,
|
const dmgSource =
|
||||||
);
|
findByExtension(artifactDir, ".dmg") ?? findByExtension(path.join(rootDir, "build"), ".dmg");
|
||||||
process.exit(0);
|
const appBundle = findMacAppBundle();
|
||||||
|
|
||||||
|
if (!dmgSource) {
|
||||||
|
throw new Error("Could not find a macOS DMG artifact to publish");
|
||||||
|
}
|
||||||
|
if (!appBundle) {
|
||||||
|
throw new Error("Could not find a macOS .app bundle to build a PKG");
|
||||||
}
|
}
|
||||||
|
|
||||||
const published = [
|
published.push(publishArtifact(dmgSource, arch, "dmg"));
|
||||||
publishArtifact(dmgSource, buildArch, "dmg"),
|
published.push(buildMacPkg(appBundle, arch));
|
||||||
buildMacPkg(appBundle, buildArch),
|
|
||||||
];
|
|
||||||
|
|
||||||
cleanStagingArtifacts(published.map((filePath) => path.basename(filePath)));
|
|
||||||
} else if (process.platform === "win32") {
|
} else if (process.platform === "win32") {
|
||||||
const arch = "x64";
|
const arch = "x64";
|
||||||
const installerFiles = findWindowsInstallerFiles();
|
const setupExe = findWindowsSetupExe();
|
||||||
|
|
||||||
if (!installerFiles) {
|
if (!setupExe) {
|
||||||
throw new Error(
|
throw new Error("Could not find the Windows setup executable to publish");
|
||||||
"Could not find the Windows installer files (setup exe, archive, and metadata)",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const published = [buildWindowsMsi(installerFiles, arch)];
|
published.push(publishArtifact(setupExe, arch, "exe"));
|
||||||
|
published.push(buildWindowsMsi(setupExe, arch));
|
||||||
if (installerFiles.setupZip) {
|
|
||||||
published.push(publishArtifact(installerFiles.setupZip, arch, "zip"));
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanStagingArtifacts(published.map((filePath) => path.basename(filePath)));
|
|
||||||
} else {
|
} else {
|
||||||
console.log("finalize-desktop-artifacts: skipping unsupported platform", process.platform);
|
console.log("finalize-desktop-artifacts: skipping unsupported platform", process.platform);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanArtifactDir(published.map((filePath) => path.basename(filePath)));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user