fix #14740: faster update retries and release safety checks
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,52 @@ command -v jq >/dev/null 2>&1 || die "jq not found on PATH"
|
||||
# shellcheck source=release.env
|
||||
source "${SCRIPT_DIR}/release.env"
|
||||
|
||||
# --- Safety checks ----------------------------------------------------------
|
||||
# The release must be built from committed sources, and the version bump this
|
||||
# script makes must be the only change to commit afterwards. Untracked files
|
||||
# are ignored.
|
||||
if [ -n "$(git -C "${REPO_ROOT}" status --porcelain --untracked-files=no)" ]; then
|
||||
if [ "${RELEASE_ALLOW_DIRTY:-}" = "1" ]; then
|
||||
echo "WARNING: building from uncommitted changes (RELEASE_ALLOW_DIRTY=1)." >&2
|
||||
else
|
||||
die "uncommitted changes to tracked files; commit them first (or reset a version bump left by a failed build):
|
||||
$(git -C "${REPO_ROOT}" status --short --untracked-files=no)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Whether semantic version $1 is greater than $2 (build metadata ignored).
|
||||
version_gt() {
|
||||
local a="${1%%+*}" b="${2%%+*}"
|
||||
local a_pre="" b_pre="" i
|
||||
[[ "${a}" == *-* ]] && a_pre="${a#*-}"
|
||||
[[ "${b}" == *-* ]] && b_pre="${b#*-}"
|
||||
local -a a_core b_core
|
||||
IFS=. read -ra a_core <<<"${a%%-*}"
|
||||
IFS=. read -ra b_core <<<"${b%%-*}"
|
||||
for i in 0 1 2; do
|
||||
((10#${a_core[i]} > 10#${b_core[i]})) && return 0
|
||||
((10#${a_core[i]} < 10#${b_core[i]})) && return 1
|
||||
done
|
||||
# Same core: a release is greater than its pre-releases.
|
||||
[ -z "${a_pre}" ] && [ -n "${b_pre}" ] && return 0
|
||||
[ -z "${a_pre}" ] || [ -z "${b_pre}" ] && return 1
|
||||
[ "${a_pre}" != "${b_pre}" ] &&
|
||||
[ "$(printf '%s\n%s\n' "${a_pre}" "${b_pre}" | sort -V | tail -n 1)" = "${a_pre}" ]
|
||||
}
|
||||
|
||||
# Installed apps only update to a greater version. The committed version may
|
||||
# be built again as long as it has not been released (no tag v<version>),
|
||||
# e.g. for the first release.
|
||||
CURRENT="$(git -C "${REPO_ROOT}" show HEAD:src-tauri/tauri.conf.json | jq -r .version)"
|
||||
if ! version_gt "${VERSION}" "${CURRENT}" &&
|
||||
! { [ "${VERSION}" = "${CURRENT}" ] && [ -z "$(git -C "${REPO_ROOT}" tag -l "v${CURRENT}")" ]; }; then
|
||||
if [ "${RELEASE_ALLOW_NOT_NEWER:-}" = "1" ]; then
|
||||
echo "WARNING: ${VERSION} is not greater than the current version ${CURRENT} (RELEASE_ALLOW_NOT_NEWER=1); installed apps will not update to it." >&2
|
||||
else
|
||||
die "${VERSION} is not greater than the current version ${CURRENT}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- Updater signing key ---------------------------------------------------
|
||||
# `cargo tauri build` reads only TAURI_SIGNING_PRIVATE_KEY (key or path).
|
||||
if [ -n "${TAURI_SIGNING_PRIVATE_KEY_PATH:-}" ]; then
|
||||
|
||||
Reference in New Issue
Block a user