Introduce new auto-updating staging channel
This commit is contained in:
parent
4038d781d6
commit
038ec9e05d
|
@ -30,6 +30,7 @@
|
|||
"prepare-beta-build": "node scripts/prepare_beta_build.js",
|
||||
"prepare-alpha-build": "node scripts/prepare_alpha_build.js",
|
||||
"prepare-alpha-version": "node scripts/prepare_alpha_version.js",
|
||||
"prepare-staging-build": "node scripts/prepare_staging_build.js",
|
||||
"prepare-windows-cert": "node scripts/prepare_windows_cert.js",
|
||||
"publish-to-apt": "NAME=$npm_package_name VERSION=$npm_package_version ./aptly.sh",
|
||||
"test": "yarn test-node && yarn test-electron",
|
||||
|
|
|
@ -16,7 +16,8 @@ const { version } = packageJson;
|
|||
// adding the ${channel} macro to these values, but Electron-Builder didn't like that.
|
||||
|
||||
if (!isAlpha(version)) {
|
||||
process.exit();
|
||||
console.error(`Version '${version}' is not an alpha version!`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('prepare_alpha_build: updating package.json');
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
const fs = require('fs');
|
||||
const _ = require('lodash');
|
||||
|
||||
const packageJson = require('../package.json');
|
||||
const { isAlpha } = require('../ts/util/version');
|
||||
|
||||
const { version } = packageJson;
|
||||
|
||||
// You might be wondering why this file is necessary. It comes down to our desire to allow
|
||||
// side-by-side installation of production and staging builds. Electron-Builder uses
|
||||
// top-level data from package.json for many things, like the executable name, the
|
||||
// debian package name, the install directory under /opt on linux, etc. We tried
|
||||
// adding the ${channel} macro to these values, but Electron-Builder didn't like that.
|
||||
|
||||
if (!isAlpha(version)) {
|
||||
console.error(`Version '${version}' is not an alpha version!`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('prepare_staging_build: updating package.json');
|
||||
|
||||
// -------
|
||||
|
||||
const VERSION_PATH = 'version';
|
||||
const STAGING_VERSION = version.replace('alpha', 'staging');
|
||||
|
||||
const NAME_PATH = 'name';
|
||||
const PRODUCTION_NAME = 'signal-desktop';
|
||||
const STAGING_NAME = 'signal-desktop-staging';
|
||||
|
||||
const PRODUCT_NAME_PATH = 'productName';
|
||||
const PRODUCTION_PRODUCT_NAME = 'Signal';
|
||||
const STAGING_PRODUCT_NAME = 'Signal Staging';
|
||||
|
||||
const APP_ID_PATH = 'build.appId';
|
||||
const PRODUCTION_APP_ID = 'org.whispersystems.signal-desktop';
|
||||
const STAGING_APP_ID = 'org.whispersystems.signal-desktop-staging';
|
||||
|
||||
const STARTUP_WM_CLASS_PATH = 'build.linux.desktop.StartupWMClass';
|
||||
const PRODUCTION_STARTUP_WM_CLASS = 'Signal';
|
||||
const STAGING_STARTUP_WM_CLASS = 'Signal Staging';
|
||||
|
||||
const DESKTOP_NAME_PATH = 'desktopName';
|
||||
|
||||
// Note: we're avoiding dashes in our .desktop name due to xdg-settings behavior
|
||||
// https://github.com/signalapp/Signal-Desktop/issues/3602
|
||||
const PRODUCTION_DESKTOP_NAME = 'signal.desktop';
|
||||
const STAGING_DESKTOP_NAME = 'signalstaging.desktop';
|
||||
|
||||
// -------
|
||||
|
||||
function checkValue(object, objectPath, expected) {
|
||||
const actual = _.get(object, objectPath);
|
||||
if (actual !== expected) {
|
||||
throw new Error(`${objectPath} was ${actual}; expected ${expected}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ------
|
||||
|
||||
checkValue(packageJson, NAME_PATH, PRODUCTION_NAME);
|
||||
checkValue(packageJson, PRODUCT_NAME_PATH, PRODUCTION_PRODUCT_NAME);
|
||||
checkValue(packageJson, APP_ID_PATH, PRODUCTION_APP_ID);
|
||||
checkValue(packageJson, STARTUP_WM_CLASS_PATH, PRODUCTION_STARTUP_WM_CLASS);
|
||||
checkValue(packageJson, DESKTOP_NAME_PATH, PRODUCTION_DESKTOP_NAME);
|
||||
|
||||
// -------
|
||||
|
||||
_.set(packageJson, VERSION_PATH, STAGING_VERSION);
|
||||
_.set(packageJson, NAME_PATH, STAGING_NAME);
|
||||
_.set(packageJson, PRODUCT_NAME_PATH, STAGING_PRODUCT_NAME);
|
||||
_.set(packageJson, APP_ID_PATH, STAGING_APP_ID);
|
||||
_.set(packageJson, STARTUP_WM_CLASS_PATH, STAGING_STARTUP_WM_CLASS);
|
||||
_.set(packageJson, DESKTOP_NAME_PATH, STAGING_DESKTOP_NAME);
|
||||
|
||||
// -------
|
||||
|
||||
fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, ' '));
|
||||
|
||||
const productionJson = {
|
||||
updatesEnabled: true,
|
||||
};
|
||||
fs.writeFileSync(
|
||||
'./config/production.json',
|
||||
JSON.stringify(productionJson, null, ' ')
|
||||
);
|
|
@ -10,6 +10,7 @@ import {
|
|||
isAlpha,
|
||||
isBeta,
|
||||
isProduction,
|
||||
isStaging,
|
||||
} from '../../util/version';
|
||||
|
||||
describe('version utilities', () => {
|
||||
|
@ -44,6 +45,7 @@ describe('version utilities', () => {
|
|||
describe('isAlpha', () => {
|
||||
it('returns false for non-alpha version strings', () => {
|
||||
assert.isFalse(isAlpha('1.2.3'));
|
||||
assert.isFalse(isAlpha('1.2.3-staging.1'));
|
||||
assert.isFalse(isAlpha('1.2.3-beta'));
|
||||
assert.isFalse(isAlpha('1.2.3-beta.1'));
|
||||
assert.isFalse(isAlpha('1.2.3-rc.1'));
|
||||
|
@ -55,6 +57,22 @@ describe('version utilities', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('isStaging', () => {
|
||||
it('returns false for non-staging version strings', () => {
|
||||
assert.isFalse(isStaging('1.2.3'));
|
||||
assert.isFalse(isStaging('1.2.3-alpha.1'));
|
||||
assert.isFalse(isStaging('1.2.3-beta'));
|
||||
assert.isFalse(isStaging('1.2.3-beta.1'));
|
||||
assert.isFalse(isStaging('1.2.3-rc.1'));
|
||||
});
|
||||
|
||||
it('returns true for Staging version strings', () => {
|
||||
assert.isTrue(isStaging('1.2.3-staging'));
|
||||
assert.isTrue(isStaging('1.2.3-staging.1'));
|
||||
assert.isTrue(isStaging('1.2.3-staging.1232.23-adsfs'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateAlphaVersion', () => {
|
||||
beforeEach(function beforeEach() {
|
||||
// This isn't a hook.
|
||||
|
|
|
@ -28,7 +28,7 @@ import * as durations from '../util/durations';
|
|||
import { getTempPath, getUpdateCachePath } from '../util/attachments';
|
||||
import { DialogType } from '../types/Dialogs';
|
||||
import * as Errors from '../types/errors';
|
||||
import { isAlpha, isBeta } from '../util/version';
|
||||
import { isAlpha, isBeta, isStaging } from '../util/version';
|
||||
import { strictAssert } from '../util/assert';
|
||||
|
||||
import * as packageJson from '../../package.json';
|
||||
|
@ -754,6 +754,9 @@ export function getUpdatesFileName(): string {
|
|||
function getChannel(): string {
|
||||
const { version } = packageJson;
|
||||
|
||||
if (isStaging(version)) {
|
||||
return 'staging';
|
||||
}
|
||||
if (isAlpha(version)) {
|
||||
return 'alpha';
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ export const isBeta = (version: string): boolean =>
|
|||
export const isAlpha = (version: string): boolean =>
|
||||
semver.parse(version)?.prerelease[0] === 'alpha';
|
||||
|
||||
export const isStaging = (version: string): boolean =>
|
||||
semver.parse(version)?.prerelease[0] === 'staging';
|
||||
|
||||
export const generateAlphaVersion = (options: {
|
||||
currentVersion: string;
|
||||
shortSha: string;
|
||||
|
|
Loading…
Reference in New Issue