fix: update release script

This commit is contained in:
eric
2026-03-04 06:23:22 +01:00
parent b72bf4f187
commit d06653a743
2 changed files with 45 additions and 33 deletions

3
VERSION Normal file
View File

@@ -0,0 +1,3 @@
0.0.2
stable
0

View File

@@ -194,8 +194,14 @@ generate_version_files() {
# ── version source (built-in) ────────────────────────────────────────────── # ── version source (built-in) ──────────────────────────────────────────────
do_read_version() { # Initializes $ROOT_DIR/VERSION from git tags if it doesn't exist.
if [[ ! -f "$ROOT_DIR/VERSION" ]]; then # Must be called outside of any subshell so log output stays on stderr
# and never contaminates the stdout of do_read_version.
init_version_file() {
if [[ -f "$ROOT_DIR/VERSION" ]]; then
return 0
fi
local highest_tag="" local highest_tag=""
while IFS= read -r raw_tag; do while IFS= read -r raw_tag; do
local tag="${raw_tag#v}" local tag="${raw_tag#v}"
@@ -223,16 +229,15 @@ do_read_version() {
printf '%s\n%s\n%s\n' "$BASE_VERSION" "$channel_to_write" "$n_to_write" > "$ROOT_DIR/VERSION" printf '%s\n%s\n%s\n' "$BASE_VERSION" "$channel_to_write" "$n_to_write" > "$ROOT_DIR/VERSION"
log "Initialized $ROOT_DIR/VERSION from highest tag: v$highest_tag" log "Initialized $ROOT_DIR/VERSION from highest tag: v$highest_tag"
fi }
do_read_version() {
local base_line channel_line n_line local base_line channel_line n_line
base_line="$(sed -n '1p' "$ROOT_DIR/VERSION" | tr -d '\r')" base_line="$(sed -n '1p' "$ROOT_DIR/VERSION" | tr -d '\r')"
channel_line="$(sed -n '2p' "$ROOT_DIR/VERSION" | tr -d '\r')" channel_line="$(sed -n '2p' "$ROOT_DIR/VERSION" | tr -d '\r')"
n_line="$(sed -n '3p' "$ROOT_DIR/VERSION" | tr -d '\r')" n_line="$(sed -n '3p' "$ROOT_DIR/VERSION" | tr -d '\r')"
if [[ -z $channel_line ]]; then if [[ -z $channel_line || $channel_line == "stable" ]]; then
printf '%s\n' "$base_line"
elif [[ $channel_line == "stable" ]]; then
printf '%s\n' "$base_line" printf '%s\n' "$base_line"
else else
printf '%s-%s.%s\n' "$base_line" "$channel_line" "$n_line" printf '%s-%s.%s\n' "$base_line" "$channel_line" "$n_line"
@@ -265,6 +270,10 @@ main() {
START_HEAD="$(git rev-parse HEAD)" START_HEAD="$(git rev-parse HEAD)"
trap revert_on_failure ERR trap revert_on_failure ERR
# Initialize VERSION file outside any subshell so log lines never
# bleed into the stdout capture below.
init_version_file
local raw_version local raw_version
raw_version="$(do_read_version | grep -E '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$' | tail -n1)" raw_version="$(do_read_version | grep -E '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$' | tail -n1)"
if [[ -z $raw_version ]]; then if [[ -z $raw_version ]]; then