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
8 changes: 4 additions & 4 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13, windows-latest]
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]

steps:
- name: Check out Git repository
Expand Down Expand Up @@ -62,11 +62,11 @@ jobs:
SHARP_IGNORE_GLOBAL_LIBVIPS: 1

- name: Install Castlabs EVS
if: matrix.os == 'macos-latest' || matrix.os == 'macos-13' || matrix.os == 'windows-latest'
if: matrix.os == 'macos-latest' || matrix.os == 'windows-latest'
run: python3 -m pip install --upgrade castlabs-evs --break-system-packages

- name: Login to Castlabs EVS (macOS)
if: matrix.os == 'macos-latest' || matrix.os == 'macos-13'
if: matrix.os == 'macos-latest'
continue-on-error: true
run: python3 -m castlabs_evs.account --no-ask reauth -A $ACCOUNT_NAME -P $PASSWD
env:
Expand All @@ -90,7 +90,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build for macOS
if: matrix.os == 'macos-latest' || matrix.os == 'macos-13'
if: matrix.os == 'macos-latest'
run: bun run build:mac -p always
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13, windows-latest]
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]

steps:
- name: Check out Git repository
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
USE_SYSTEM_FPM: ${{ matrix.os == 'ubuntu-24.04-arm' }}

- name: Build for macOS
if: matrix.os == 'macos-latest' || matrix.os == 'macos-13'
if: matrix.os == 'macos-latest'
run: bun run build:mac -p never

- name: Build for Windows
Expand Down Expand Up @@ -126,7 +126,6 @@ jobs:
- [Linux](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/ubuntu-latest.zip)
- [Linux (arm64)](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/ubuntu-24.04-arm.zip)
- [macOS](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/macos-latest.zip)
- [macOS (Intel)](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/macos-13.zip)
- [Windows](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/windows-latest.zip)

_(execution **${{ github.run_id }}** / attempt **${{ github.run_attempt }}**)_
Expand Down
23 changes: 23 additions & 0 deletions build/hooks/afterExtract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { removeWidevineSignature } from "./components/castlabs-evs.js";

// Set this to true if you're building for universal
const MACOS_IS_UNIVERSAL = true;

/** @type {(context: import("./types.js").PackContext) => void} */
export async function handler(context) {
// Header
console.log("\n---------");
console.log("Executing afterExtract hook");

// Remove `.sig` file which is causing universal builds to fail
if (process.platform === "darwin" && MACOS_IS_UNIVERSAL) {
await removeWidevineSignature(context.appOutDir)
.then(() => true)
.catch(() => false);
}

// Footer
console.log("---------\n");
}

export default handler;
20 changes: 17 additions & 3 deletions build/hooks/afterPack.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { createNotarizationApiKeyFile } from "./components/notarization.js";

const vmpSignPlatforms = ["darwin"];

// Set this to true if you're building for universal
const MACOS_IS_UNIVERSAL = true;

/** @type {(context: import("./types.js").PackContext) => void} */
export async function handler(context) {
// Header
Expand All @@ -11,9 +14,20 @@ export async function handler(context) {

// macOS needs to VMP-sign the app before signing it with Apple
if (vmpSignPlatforms.includes(process.platform)) {
await signAppWithVMP(context.appOutDir)
.then(() => true)
.catch(() => false);
let shouldSign = true;
if (process.platform === "darwin" && MACOS_IS_UNIVERSAL) {
const appOutDir = context.appOutDir;
// Only sign the universal build, not the unmerged builds
if (!appOutDir.endsWith("/mac-universal")) {
shouldSign = false;
}
}

if (shouldSign) {
await signAppWithVMP(context.appOutDir)
.then(() => true)
.catch(() => false);
}
}

// macOS needs to notarize the app with a path to APPLE_API_KEY
Expand Down
21 changes: 20 additions & 1 deletion build/hooks/components/castlabs-evs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// https://github.com/castlabs/electron-releases/wiki/EVS

import process from "process";
import path from "node:path";
import fs from "node:fs";
import { spawn } from "child_process";

/** @type {(appOutDir: string) => Promise<void>} */
Expand Down Expand Up @@ -54,4 +56,21 @@ async function signAppWithVMP(appOutDir) {
}
}

export { signAppWithVMP };
/** @type {(appOutDir: string) => Promise<void>} */
async function removeWidevineSignature(appOutDir) {
const sigFile = path.join(
appOutDir,
"Electron.app",
"Contents/Frameworks/Electron Framework.framework/Versions/A/Resources",
"Electron Framework.sig"
);
if (fs.existsSync(sigFile)) {
console.log(`\nRemoving Development Widevine Signature`);
console.log(`${sigFile}`);
fs.unlinkSync(sigFile);
} else {
console.log(`\nNo Development Widevine Signature found`);
}
}

export { signAppWithVMP, removeWidevineSignature };
7 changes: 5 additions & 2 deletions electron-builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@
"owner": "multiboxlabs",
"releaseType": "prerelease"
},
"electronDist": "node_modules/electron/dist",
"electronDownload": {
"mirror": "https://github.com/castlabs/electron-releases/releases/download/v"
},
"afterPack": "./build/hooks/afterPack.js",
"afterSign": "./build/hooks/afterSign.js"
"afterSign": "./build/hooks/afterSign.js",
"afterExtract": "./build/hooks/afterExtract.js"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"postinstall": "electron-builder install-app-deps",
"build:unpack": "npm run build && electron-builder --dir",
"build:win": "npm run build && electron-builder --win",
"build:mac": "electron-vite build && electron-builder --mac",
"build:mac": "electron-vite build && electron-builder --mac --universal",
"build:linux": "electron-vite build && electron-builder --linux",
"script:use-stock-electron": "bun run scripts/use-stock-electron.ts",
"script:upgrade-electron-to-current": "bun run scripts/electron-upgrader/current.ts",
Expand Down
38 changes: 38 additions & 0 deletions scripts/use-stock-electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,39 @@ function updateBunLock(electronVersion: string) {
fs.writeFileSync(bunLockPath, updatedContent);
}

/**
* Updates the electron-builder.json file to remove electronDownload and add electronDist
*/
function updateElectronBuilderJson() {
const electronBuilderPath = path.join(process.cwd(), "electron-builder.json");

// Check if file exists
if (!fs.existsSync(electronBuilderPath)) {
console.log("⚠️ electron-builder.json not found, skipping...");
return;
}

// Read and parse electron-builder.json
const electronBuilderContent = fs.readFileSync(electronBuilderPath, "utf8");
const electronBuilder = jju.parse(electronBuilderContent);

// Remove electronDownload key if it exists
if (electronBuilder.electronDownload) {
delete electronBuilder.electronDownload;
}

// Add electronDist key
electronBuilder.electronDist = "node_modules/electron/dist";

// Write back to electron-builder.json with preserved formatting
const updatedContent = jju.update(electronBuilderContent, electronBuilder, {
mode: "json",
indent: 2
});

fs.writeFileSync(electronBuilderPath, updatedContent);
}

/**
* Parse command line arguments
*/
Expand Down Expand Up @@ -162,6 +195,11 @@ async function main() {
updateBunLock(electronVersion);
console.log("✅ bun.lock updated!");

// Update electron-builder.json
console.log("⚙️ Updating electron-builder.json...");
updateElectronBuilderJson();
console.log("✅ electron-builder.json updated!");

console.log(`🎉 Successfully updated Electron to standard npm version ${electronVersion}`);
console.log("💡 Note: This switches from castlabs/electron-releases to standard electron");
console.log("🔄 Run 'bun install' to apply the changes");
Expand Down