Add script for linux build targets

This commit is contained in:
ayumi-signal
2025-10-06 10:13:10 -07:00
committed by GitHub
parent 2af0795347
commit e912fad9c9
4 changed files with 47 additions and 3 deletions

View File

@@ -45,6 +45,7 @@
"prepare-adhoc-build": "node scripts/prepare_adhoc_build.js",
"prepare-adhoc-version": "node scripts/prepare_tagged_version.js adhoc",
"prepare-staging-build": "node scripts/prepare_staging_build.js",
"prepare-linux-build": "node scripts/prepare_linux_build.js",
"test": "run-s test-node test-electron test-lint-intl test-eslint",
"test-electron": "node ts/scripts/test-electron.js",
"test-release": "node ts/scripts/test-release.js",

View File

@@ -3,7 +3,15 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Usage:
# ./build.sh [ dev (default) | public (prod and beta builds) | alpha | test | staging ] [ Build timestamp override. Defaults to latest git commit or 1. ]
# ./build.sh [ dev (default) | public (prod and beta builds) | alpha | test | staging ]
# Env vars:
# SOURCE_DATE_EPOCH: Build timestamp override. Defaults to latest git commit or 1.
# SKIP_DOCKER_BUILD: To support docker build cache during actions.
# BUILD_TARGETS: Override build targets. Empty default results in deb.
# Examples:
# ./build.sh public
# SOURCE_DATE_EPOCH=123 ./build.sh test
# First we prepare the docker container in which our build scripts will run. This container includes
# all build dependencies at specific versions.
@@ -19,9 +27,9 @@ cd ..
# Prepare the timestamp of the actual build based on the latest git commit.
source_date_epoch=1
if [ "$2" != "" ]; then
if [ -n "${SOURCE_DATE_EPOCH}" ]; then
echo "Using override timestamp for SOURCE_DATE_EPOCH."
source_date_epoch=$(($2))
source_date_epoch="${SOURCE_DATE_EPOCH}"
else
git_timestamp=$(git log -1 --pretty=%ct)
if [ "${git_timestamp}" != "" ]; then
@@ -45,4 +53,5 @@ docker run --rm \
-e NPM_CONFIG_CACHE=/tmp/.npm-cache \
-e PNPM_HOME=/tmp/.pnpm-home \
-e SOURCE_DATE_EPOCH=$source_date_epoch \
-e BUILD_TARGETS=$BUILD_TARGETS \
signal-desktop $1

View File

@@ -66,4 +66,8 @@ else
exit 1
fi
if [ "${BUILD_TARGETS}" != "" ]; then
pnpm run prepare-linux-build $BUILD_TARGETS
fi
pnpm run build-linux

View File

@@ -0,0 +1,30 @@
// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
const fs = require('node:fs');
const _ = require('lodash');
const TARGETS = new Set(['appimage', 'deb']);
const targets = (process.argv[2] || '').split(',');
if (
targets.length === 0 ||
!targets.every(target => TARGETS.has(target.toLowerCase()))
) {
console.error(
`Invalid linux targets ${targets}. Valid options: ${[...TARGETS]}`
);
process.exit(1);
}
const { default: packageJson } = require('./packageJson.js');
console.log('prepare_linux_build: updating package.json');
// ------
_.set(packageJson, 'build.linux.target', targets);
// -------
fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, ' '));