Revert "Switch to a build variant config instead of magic env vars (#2498)" (#2520)

This commit is contained in:
Michael Telatynski
2025-08-28 11:33:39 +01:00
committed by GitHub
parent a50957973b
commit bcde9afce9
7 changed files with 43 additions and 83 deletions
+1 -2
View File
@@ -145,9 +145,8 @@ jobs:
- name: Build App - name: Build App
run: yarn build --publish never -l ${{ steps.config.outputs.build-args }} run: yarn build --publish never -l ${{ steps.config.outputs.build-args }}
env: env:
VARIANT_PATH: variant.json
# Only set for Nightly builds # Only set for Nightly builds
VERSION: ${{ inputs.version }} ED_NIGHTLY: ${{ inputs.version }}
- name: Check native libraries - name: Check native libraries
run: | run: |
+1 -3
View File
@@ -96,9 +96,8 @@ jobs:
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
CSC_KEY_PASSWORD: ${{ secrets.APPLE_CSC_KEY_PASSWORD }} CSC_KEY_PASSWORD: ${{ secrets.APPLE_CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.APPLE_CSC_LINK }} CSC_LINK: ${{ secrets.APPLE_CSC_LINK }}
VARIANT_PATH: variant.json
# Only set for Nightly builds # Only set for Nightly builds
VERSION: ${{ inputs.version }} ED_NIGHTLY: ${{ inputs.version }}
- name: Check app was signed & notarised successfully - name: Check app was signed & notarised successfully
if: inputs.sign != '' if: inputs.sign != ''
@@ -114,7 +113,6 @@ jobs:
yarn build:universal --publish never yarn build:universal --publish never
env: env:
CSC_IDENTITY_AUTO_DISCOVERY: false CSC_IDENTITY_AUTO_DISCOVERY: false
VARIANT_PATH: variant.json
- name: Generate releases.json - name: Generate releases.json
if: inputs.base-url if: inputs.base-url
-6
View File
@@ -85,11 +85,6 @@ jobs:
if: steps.branch-matching.outcome == 'failure' || steps.branch-matching.outcome == 'skipped' if: steps.branch-matching.outcome == 'failure' || steps.branch-matching.outcome == 'skipped'
run: yarn run fetch --noverify -d ${{ inputs.config }} ${{ inputs.version }} run: yarn run fetch --noverify -d ${{ inputs.config }} ${{ inputs.version }}
- name: Copy variant config
run: cp "$CONFIG_DIR/build.json" variant.json
env:
CONFIG_DIR: ${{ inputs.config }}
# We split this out to save the build_* scripts having to do it to make use of `hashFiles` in the cache action # We split this out to save the build_* scripts having to do it to make use of `hashFiles` in the cache action
- name: Generate cache hash files - name: Generate cache hash files
run: | run: |
@@ -175,4 +170,3 @@ jobs:
electronVersion electronVersion
hakHash hakHash
changelog.Debian changelog.Debian
variant.json
+1 -7
View File
@@ -193,14 +193,8 @@ jobs:
- name: Build App - name: Build App
run: yarn build --publish never -w ${{ steps.config.outputs.build-args }} run: yarn build --publish never -w ${{ steps.config.outputs.build-args }}
env: env:
VARIANT_PATH: variant.json
# Only set for Nightly builds # Only set for Nightly builds
# The windows packager relies on parsing this as semver, so we have to make it look like one. ED_NIGHTLY: ${{ inputs.version }}
# This will give our update packages really stupid names, but we probably can't change that either
# because squirrel windows parses them for the version too. We don't really care: nobody sees them.
# We just give the installer a static name, so you'll just see this in the 'about' dialog.
# Turns out if you use 0.0.0 here it makes Squirrel windows crash, so we use 0.0.1.
VERSION: ${{ inputs.version && format('0.0.1-nightly.{0}', inputs.version) || '' }}
- name: Trust eSigner sandbox cert - name: Trust eSigner sandbox cert
if: inputs.sign == '' if: inputs.sign == ''
+40 -49
View File
@@ -1,12 +1,12 @@
import * as os from "node:os"; import * as os from "node:os";
import * as fs from "node:fs"; import * as fs from "node:fs";
import * as path from "node:path";
import { type Configuration as BaseConfiguration, type Protocol } from "electron-builder"; import { type Configuration as BaseConfiguration, type Protocol } from "electron-builder";
/** /**
* This script has different outputs depending on your os platform. * This script has different outputs depending on your os platform.
* *
* On Windows: * On Windows:
* Prefixes the nightly version with `0.0.1-nightly.` as it breaks if it is not semver
* Passes $ED_SIGNTOOL_THUMBPRINT and $ED_SIGNTOOL_SUBJECT_NAME to * Passes $ED_SIGNTOOL_THUMBPRINT and $ED_SIGNTOOL_SUBJECT_NAME to
* build.win.signtoolOptions.signingHashAlgorithms and build.win.signtoolOptions.certificateSubjectName respectively if specified. * build.win.signtoolOptions.signingHashAlgorithms and build.win.signtoolOptions.certificateSubjectName respectively if specified.
* *
@@ -16,9 +16,13 @@ import { type Configuration as BaseConfiguration, type Protocol } from "electron
* Passes $ED_DEBIAN_CHANGELOG to build.deb.fpm if specified * Passes $ED_DEBIAN_CHANGELOG to build.deb.fpm if specified
*/ */
/** const DEFAULT_APP_ID = "im.riot.app";
* Interface describing relevant fields of the package.json file. const NIGHTLY_APP_ID = "im.riot.nightly";
*/ const NIGHTLY_DEB_NAME = "element-nightly";
const DEFAULT_PROTOCOL_SCHEME = "io.element.desktop";
const NIGHTLY_PROTOCOL_SCHEME = "io.element.nightly";
interface Pkg { interface Pkg {
name: string; name: string;
productName: string; productName: string;
@@ -26,38 +30,11 @@ interface Pkg {
version: string; version: string;
} }
/**
* Interface describing the variant configuration format.
*/
interface Variant extends Omit<Pkg, "version"> {
"appId": string;
"linux.executableName"?: string;
"linux.deb.name"?: string;
"protocols": string[];
}
type Writable<T> = NonNullable< type Writable<T> = NonNullable<
T extends Function ? T : T extends object ? { -readonly [K in keyof T]: Writable<T[K]> } : T T extends Function ? T : T extends object ? { -readonly [K in keyof T]: Writable<T[K]> } : T
>; >;
// Load the package.json file to get the app metadata
const pkg: Pkg = JSON.parse(fs.readFileSync("package.json", "utf8")); const pkg: Pkg = JSON.parse(fs.readFileSync("package.json", "utf8"));
// Load the default variant as a base configuration
let variant: Variant = {
...pkg,
...JSON.parse(fs.readFileSync(path.join("element.io", "release", "build.json"), "utf8")),
};
/**
* If a variant is specified, we will use it to override the build-specific values.
* This allows us to have different builds for different purposes (e.g. stable, nightly).
*/
if (process.env.VARIANT_PATH) {
variant = {
...variant,
...JSON.parse(fs.readFileSync(`${process.env.VARIANT_PATH}`, "utf8")),
};
}
interface Configuration extends BaseConfiguration { interface Configuration extends BaseConfiguration {
extraMetadata: Partial<Pick<Pkg, "version">> & extraMetadata: Partial<Pick<Pkg, "version">> &
@@ -81,7 +58,7 @@ const config: Omit<Writable<Configuration>, "electronFuses"> & {
// Make all fuses required to ensure they are all explicitly specified // Make all fuses required to ensure they are all explicitly specified
electronFuses: Required<Configuration["electronFuses"]>; electronFuses: Required<Configuration["electronFuses"]>;
} = { } = {
appId: variant.appId, appId: DEFAULT_APP_ID,
asarUnpack: "**/*.node", asarUnpack: "**/*.node",
electronFuses: { electronFuses: {
enableCookieEncryption: true, enableCookieEncryption: true,
@@ -110,8 +87,8 @@ const config: Omit<Writable<Configuration>, "electronFuses"> & {
name: pkg.name, name: pkg.name,
productName: pkg.productName, productName: pkg.productName,
description: pkg.description, description: pkg.description,
electron_appId: variant.appId, electron_appId: DEFAULT_APP_ID,
electron_protocol: variant.protocols[0], electron_protocol: DEFAULT_PROTOCOL_SCHEME,
}, },
linux: { linux: {
target: ["tar.gz", "deb"], target: ["tar.gz", "deb"],
@@ -163,27 +140,14 @@ const config: Omit<Writable<Configuration>, "electronFuses"> & {
output: "dist", output: "dist",
}, },
protocols: { protocols: {
name: variant.productName, name: "element",
schemes: variant.protocols, schemes: [DEFAULT_PROTOCOL_SCHEME, "element"],
}, },
nativeRebuilder: "sequential", nativeRebuilder: "sequential",
nodeGypRebuild: false, nodeGypRebuild: false,
npmRebuild: true, npmRebuild: true,
}; };
/**
* Allow specifying the version via env var.
* If unspecified, it will default to the version in package.json.
* @param {string} process.env.VERSION
*/
if (process.env.VERSION) {
config.extraMetadata.version = process.env.VERSION;
}
if (variant["linux.deb.name"]) {
config.deb.fpm.push("--name", variant["linux.deb.name"]);
}
/** /**
* Allow specifying windows signing cert via env vars * Allow specifying windows signing cert via env vars
* @param {string} process.env.ED_SIGNTOOL_SUBJECT_NAME * @param {string} process.env.ED_SIGNTOOL_SUBJECT_NAME
@@ -194,6 +158,33 @@ if (process.env.ED_SIGNTOOL_SUBJECT_NAME && process.env.ED_SIGNTOOL_THUMBPRINT)
config.win.signtoolOptions!.certificateSha1 = process.env.ED_SIGNTOOL_THUMBPRINT; config.win.signtoolOptions!.certificateSha1 = process.env.ED_SIGNTOOL_THUMBPRINT;
} }
/**
* Allow specifying nightly version via env var
* @param {string} process.env.ED_NIGHTLY
*/
if (process.env.ED_NIGHTLY) {
config.deb.fpm = []; // Clear the fpm as the breaks deb fields don't apply to nightly
config.appId = config.extraMetadata.electron_appId = NIGHTLY_APP_ID;
config.extraMetadata.productName += " Nightly";
config.extraMetadata.name += "-nightly";
config.extraMetadata.description += " (nightly unstable build)";
config.linux.executableName += "-nightly";
config.deb.fpm.push("--name", NIGHTLY_DEB_NAME);
(config.protocols as Protocol).schemes[0] = config.extraMetadata.electron_protocol = NIGHTLY_PROTOCOL_SCHEME;
let version = process.env.ED_NIGHTLY;
if (os.platform() === "win32") {
// The windows packager relies on parsing this as semver, so we have to make it look like one.
// This will give our update packages really stupid names, but we probably can't change that either
// because squirrel windows parses them for the version too. We don't really care: nobody sees them.
// We just give the installer a static name, so you'll just see this in the 'about' dialog.
// Turns out if you use 0.0.0 here it makes Squirrel windows crash, so we use 0.0.1.
version = "0.0.1-nightly." + version;
}
config.extraMetadata.version = version;
}
if (os.platform() === "linux") { if (os.platform() === "linux") {
// Electron crashes on debian if there's a space in the path. // Electron crashes on debian if there's a space in the path.
// https://github.com/vector-im/element-web/issues/13171 // https://github.com/vector-im/element-web/issues/13171
-9
View File
@@ -1,9 +0,0 @@
{
"appId": "im.riot.nightly",
"name": "element-desktop-nightly",
"productName": "Element Nightly",
"description": "Element: the future of secure communication (nightly unstable build)",
"protocols": ["io.element.nightly", "element"],
"linux.executableName": "element-desktop-nightly",
"linux.deb.name": "element-nightly"
}
-7
View File
@@ -1,7 +0,0 @@
{
"appId": "im.riot.app",
"name": "element-desktop",
"productName": "Element",
"description": "Element: the future of secure communication",
"protocols": ["io.element.desktop", "element"]
}