feat #14740: updater and release scripts
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Executable
+147
@@ -0,0 +1,147 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds a signed release of Gesprächsrekorder into dist-release/<version>/:
|
||||
# the Windows NSIS installer (cross-built via build-windows.sh), the Linux
|
||||
# deb and AppImage, their updater signatures (.sig) and latest.json.
|
||||
# Sets <version> in tauri.conf.json, src-tauri/Cargo.toml and
|
||||
# ui/package.json and leaves those changes for you to commit. Never tags or
|
||||
# publishes anything; see RELEASING.md.
|
||||
#
|
||||
# Usage: scripts/build-release.sh <version> (e.g. 0.1.1)
|
||||
#
|
||||
# The updater private key comes from TAURI_SIGNING_PRIVATE_KEY_PATH (a file)
|
||||
# or TAURI_SIGNING_PRIVATE_KEY (the key or a file), its password from
|
||||
# TAURI_SIGNING_PRIVATE_KEY_PASSWORD (asked for when unset).
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)"
|
||||
REPO_ROOT="$(cd -- "${SCRIPT_DIR}/.." >/dev/null 2>&1 && pwd -P)"
|
||||
|
||||
export PATH="${HOME}/.cargo/bin:${PATH}"
|
||||
|
||||
CONF="${REPO_ROOT}/src-tauri/tauri.conf.json"
|
||||
CARGO_TOML="${REPO_ROOT}/src-tauri/Cargo.toml"
|
||||
PACKAGE_JSON="${REPO_ROOT}/ui/package.json"
|
||||
WINDOWS_BUNDLE="${REPO_ROOT}/target/x86_64-pc-windows-msvc/release/bundle/nsis"
|
||||
LINUX_BUNDLE="${REPO_ROOT}/target/release/bundle"
|
||||
|
||||
die() {
|
||||
echo "build-release: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ "$#" -eq 1 ] || die "usage: scripts/build-release.sh <version> (e.g. 0.1.1)"
|
||||
VERSION="${1#v}"
|
||||
SEMVER='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'
|
||||
[[ "${VERSION}" =~ ${SEMVER} ]] || die "'$1' is not a semantic version (e.g. 0.1.1)"
|
||||
command -v jq >/dev/null 2>&1 || die "jq not found on PATH"
|
||||
|
||||
# shellcheck source=release.env
|
||||
source "${SCRIPT_DIR}/release.env"
|
||||
|
||||
# --- Updater signing key ---------------------------------------------------
|
||||
# `cargo tauri build` reads only TAURI_SIGNING_PRIVATE_KEY (key or path).
|
||||
if [ -n "${TAURI_SIGNING_PRIVATE_KEY_PATH:-}" ]; then
|
||||
[ -f "${TAURI_SIGNING_PRIVATE_KEY_PATH}" ] ||
|
||||
die "TAURI_SIGNING_PRIVATE_KEY_PATH points to no file: ${TAURI_SIGNING_PRIVATE_KEY_PATH}"
|
||||
export TAURI_SIGNING_PRIVATE_KEY="${TAURI_SIGNING_PRIVATE_KEY_PATH}"
|
||||
elif [ -z "${TAURI_SIGNING_PRIVATE_KEY:-}" ]; then
|
||||
die "no updater signing key. Set TAURI_SIGNING_PRIVATE_KEY_PATH=~/.tauri/call-recorder.key
|
||||
(or TAURI_SIGNING_PRIVATE_KEY) and, if the key has one, TAURI_SIGNING_PRIVATE_KEY_PASSWORD.
|
||||
See RELEASING.md."
|
||||
fi
|
||||
if [ -z "${TAURI_SIGNING_PRIVATE_KEY_PASSWORD+set}" ]; then
|
||||
if [ -t 0 ]; then
|
||||
read -rsp "Password of the updater signing key (empty if none): " TAURI_SIGNING_PRIVATE_KEY_PASSWORD
|
||||
echo
|
||||
else
|
||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD=""
|
||||
fi
|
||||
fi
|
||||
export TAURI_SIGNING_PRIVATE_KEY_PASSWORD
|
||||
|
||||
WORK_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "${WORK_DIR}"' EXIT
|
||||
|
||||
# Key id of a minisign public key or signature (base64 of the minisign text;
|
||||
# its second line holds the algorithm, then the 8-byte little-endian key id),
|
||||
# as minisign prints it.
|
||||
keynum() {
|
||||
base64 -d | sed -n 2p | base64 -d | od -An -tx8 -j2 -N8 | tr -d ' \n' | tr a-f A-F
|
||||
}
|
||||
|
||||
# Sign a probe file before the long build: a wrong key or password fails
|
||||
# here, and a key that does not belong to plugins.updater.pubkey would make
|
||||
# every installed app reject the update.
|
||||
echo "probe" >"${WORK_DIR}/probe"
|
||||
if [ -f "${TAURI_SIGNING_PRIVATE_KEY}" ]; then
|
||||
probe_env=(env -u TAURI_SIGNING_PRIVATE_KEY TAURI_SIGNING_PRIVATE_KEY_PATH="${TAURI_SIGNING_PRIVATE_KEY}")
|
||||
else
|
||||
probe_env=(env -u TAURI_SIGNING_PRIVATE_KEY_PATH)
|
||||
fi
|
||||
"${probe_env[@]}" cargo tauri signer sign "${WORK_DIR}/probe" >/dev/null ||
|
||||
die "signing with the updater key failed (wrong key or password?)"
|
||||
key_of_signature="$(keynum <"${WORK_DIR}/probe.sig")"
|
||||
key_of_config="$(jq -r '.plugins.updater.pubkey' "${CONF}" | keynum)"
|
||||
if [ "${key_of_signature}" != "${key_of_config}" ]; then
|
||||
if [ "${RELEASE_ALLOW_KEY_MISMATCH:-}" = "1" ]; then
|
||||
echo "WARNING: the signing key does not match plugins.updater.pubkey; installed apps will reject this release (RELEASE_ALLOW_KEY_MISMATCH=1, test builds only)." >&2
|
||||
else
|
||||
die "the signing key (key id ${key_of_signature}) does not match plugins.updater.pubkey in tauri.conf.json (key id ${key_of_config})"
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- Version and update feed ------------------------------------------------
|
||||
echo "Setting version ${VERSION} and update feed ${UPDATE_JSON_URL}"
|
||||
# Rewrites a JSON file in place, keeping its permissions.
|
||||
jq_in_place() {
|
||||
local file="$1"
|
||||
shift
|
||||
jq "$@" "${file}" >"${WORK_DIR}/edit.json"
|
||||
cat "${WORK_DIR}/edit.json" >"${file}"
|
||||
}
|
||||
jq_in_place "${CONF}" --arg version "${VERSION}" --arg url "${UPDATE_JSON_URL}" \
|
||||
'.version = $version | .plugins.updater.endpoints = [$url]'
|
||||
jq_in_place "${PACKAGE_JSON}" --arg version "${VERSION}" '.version = $version'
|
||||
# The first `version = …` line is the one of [package].
|
||||
sed -i -E "0,/^version = \"[^\"]*\"/s//version = \"${VERSION}\"/" "${CARGO_TOML}"
|
||||
grep -qx "version = \"${VERSION}\"" "${CARGO_TOML}" || die "could not set the version in ${CARGO_TOML}"
|
||||
|
||||
# --- Build ------------------------------------------------------------------
|
||||
"${SCRIPT_DIR}/build-windows.sh"
|
||||
(cd "${REPO_ROOT}" && cargo tauri build --bundles deb appimage)
|
||||
|
||||
# --- Collect ----------------------------------------------------------------
|
||||
OUT="${REPO_ROOT}/dist-release/${VERSION}"
|
||||
rm -rf "${OUT}"
|
||||
mkdir -p "${OUT}"
|
||||
|
||||
# Copies the one artifact matching the glob $2 in $1 and its .sig into OUT,
|
||||
# under an ASCII name (the product name has an umlaut; download URLs and
|
||||
# release assets stay plain).
|
||||
collect() {
|
||||
local matches=()
|
||||
local file
|
||||
for file in "$1"/$2; do
|
||||
[ -f "${file}" ] && matches+=("${file}")
|
||||
done
|
||||
[ "${#matches[@]}" -eq 1 ] || die "expected exactly one $2 in $1, found ${#matches[@]}"
|
||||
[ -s "${matches[0]}.sig" ] || die "missing updater signature ${matches[0]}.sig"
|
||||
local name
|
||||
name="$(basename "${matches[0]}" | sed 's/ä/ae/g; s/ö/oe/g; s/ü/ue/g; s/Ä/Ae/g; s/Ö/Oe/g; s/Ü/Ue/g; s/ß/ss/g')"
|
||||
[[ "${name}" =~ ^[A-Za-z0-9._+-]+$ ]] || die "unexpected characters in artifact name: ${name}"
|
||||
cp "${matches[0]}" "${OUT}/${name}"
|
||||
cp "${matches[0]}.sig" "${OUT}/${name}.sig"
|
||||
}
|
||||
collect "${WINDOWS_BUNDLE}" "*_${VERSION}_x64-setup.exe"
|
||||
collect "${LINUX_BUNDLE}/deb" "*_${VERSION}_amd64.deb"
|
||||
collect "${LINUX_BUNDLE}/appimage" "*_${VERSION}_amd64.AppImage"
|
||||
|
||||
"${SCRIPT_DIR}/make-latest-json.sh" "${VERSION}" "${OUT}"
|
||||
jq -e . "${OUT}/latest.json" >/dev/null || die "latest.json is not valid JSON"
|
||||
|
||||
echo
|
||||
echo "Release ${VERSION} built in ${OUT}:"
|
||||
ls -1 "${OUT}"
|
||||
echo
|
||||
echo "Next (see RELEASING.md): commit the version bump, tag v${VERSION},"
|
||||
echo "create the Gitea release v${VERSION} and upload every file above."
|
||||
@@ -3,6 +3,10 @@
|
||||
# using cargo-xwin (MSVC cross-linking) and makensis for bundling.
|
||||
#
|
||||
# Usage: scripts/build-windows.sh
|
||||
#
|
||||
# Without an updater signing key (TAURI_SIGNING_PRIVATE_KEY) the installer is
|
||||
# built without updater artifacts; scripts/build-release.sh sets the key and
|
||||
# builds the signed release.
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)"
|
||||
@@ -36,10 +40,17 @@ fi
|
||||
|
||||
cd "${REPO_ROOT}"
|
||||
|
||||
config_args=()
|
||||
if [ -z "${TAURI_SIGNING_PRIVATE_KEY:-}" ]; then
|
||||
echo "No TAURI_SIGNING_PRIVATE_KEY set: building without updater artifacts."
|
||||
config_args=(--config '{"bundle":{"createUpdaterArtifacts":false}}')
|
||||
fi
|
||||
|
||||
cargo tauri build \
|
||||
--runner cargo-xwin \
|
||||
--target "${TARGET}" \
|
||||
--bundles nsis
|
||||
--bundles nsis \
|
||||
"${config_args[@]}"
|
||||
|
||||
BUNDLE_DIR="${REPO_ROOT}/target/${TARGET}/release/bundle/nsis"
|
||||
|
||||
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
# Writes <dir>/latest.json, the update feed the app reads, from the signed
|
||||
# release artifacts in <dir>:
|
||||
# windows-x86_64 -> *_<version>_x64-setup.exe (+ .sig)
|
||||
# linux-x86_64 -> *_<version>_amd64.AppImage (+ .sig)
|
||||
# The download URLs point at ${RELEASE_BASE_URL}/releases/download/v<version>/
|
||||
# (scripts/release.env).
|
||||
#
|
||||
# Usage: scripts/make-latest-json.sh <version> <dir>
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)"
|
||||
|
||||
die() {
|
||||
echo "make-latest-json: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ "$#" -eq 2 ] || die "usage: scripts/make-latest-json.sh <version> <dir>"
|
||||
VERSION="$1"
|
||||
DIR="$2"
|
||||
[ -d "${DIR}" ] || die "no such directory: ${DIR}"
|
||||
command -v jq >/dev/null 2>&1 || die "jq not found on PATH"
|
||||
|
||||
# shellcheck source=release.env
|
||||
source "${SCRIPT_DIR}/release.env"
|
||||
|
||||
# The one file in DIR matching the glob $1, with its .sig next to it.
|
||||
signed_file() {
|
||||
local matches=()
|
||||
local file
|
||||
for file in "${DIR}"/$1; do
|
||||
[ -f "${file}" ] && matches+=("${file}")
|
||||
done
|
||||
[ "${#matches[@]}" -eq 1 ] || die "expected exactly one $1 in ${DIR}, found ${#matches[@]}"
|
||||
[ -s "${matches[0]}.sig" ] || die "missing signature ${matches[0]}.sig"
|
||||
echo "${matches[0]}"
|
||||
}
|
||||
|
||||
WINDOWS="$(signed_file "*_${VERSION}_x64-setup.exe")"
|
||||
LINUX="$(signed_file "*_${VERSION}_amd64.AppImage")"
|
||||
|
||||
jq -n \
|
||||
--arg version "${VERSION}" \
|
||||
--arg pub_date "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||
--arg base "${RELEASE_BASE_URL}/releases/download/v${VERSION}" \
|
||||
--arg windows_file "$(basename "${WINDOWS}")" \
|
||||
--rawfile windows_sig "${WINDOWS}.sig" \
|
||||
--arg linux_file "$(basename "${LINUX}")" \
|
||||
--rawfile linux_sig "${LINUX}.sig" \
|
||||
'{
|
||||
version: $version,
|
||||
pub_date: $pub_date,
|
||||
platforms: {
|
||||
"windows-x86_64": {
|
||||
signature: ($windows_sig | gsub("\\s"; "")),
|
||||
url: "\($base)/\($windows_file | @uri)"
|
||||
},
|
||||
"linux-x86_64": {
|
||||
signature: ($linux_sig | gsub("\\s"; "")),
|
||||
url: "\($base)/\($linux_file | @uri)"
|
||||
}
|
||||
}
|
||||
}' >"${DIR}/latest.json"
|
||||
|
||||
echo "Wrote ${DIR}/latest.json"
|
||||
@@ -0,0 +1,14 @@
|
||||
# Where Gesprächsrekorder releases are published: the one place to change.
|
||||
# Sourced by build-release.sh, which writes UPDATE_JSON_URL into
|
||||
# src-tauri/tauri.conf.json (plugins.updater.endpoints), and by
|
||||
# make-latest-json.sh, which points the download URLs in latest.json at
|
||||
# ${RELEASE_BASE_URL}/releases/download/v<version>/<file>. See RELEASING.md.
|
||||
|
||||
RELEASE_BASE_URL="https://gitea.euvino.eu/public/call-recorder"
|
||||
|
||||
# Where the app looks for latest.json.
|
||||
# A (default): latest.json is an asset of the newest release.
|
||||
UPDATE_JSON_URL="${RELEASE_BASE_URL}/releases/latest/download/latest.json"
|
||||
# B: latest.json is committed to the root of master (if Gitea does not
|
||||
# serve releases/latest/download/…):
|
||||
# UPDATE_JSON_URL="${RELEASE_BASE_URL}/raw/branch/master/latest.json"
|
||||
Reference in New Issue
Block a user