5 Commits

Author SHA1 Message Date
eric
db4ed150e0 chore(release): v0.0.2 2026-03-04 06:58:22 +01:00
eric
a5958b3827 fix: update release script 2026-03-04 06:58:15 +01:00
eric
d06653a743 fix: update release script 2026-03-04 06:23:22 +01:00
eric
b72bf4f187 fix: release anyway 2026-03-04 06:15:23 +01:00
eric
c13502761c fix: run release even if the file does not exist the first time 2026-03-04 06:12:50 +01:00
4 changed files with 53 additions and 36 deletions

3
VERSION Normal file
View File

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

View File

@@ -122,6 +122,7 @@
${pre-commit-check.shellHook} ${pre-commit-check.shellHook}
if [ -t 1 ]; then if [ -t 1 ]; then
:
# command -v tput >/dev/null 2>&1 && tput clear || printf '\033c' # command -v tput >/dev/null 2>&1 && tput clear || printf '\033c'
fi fi

View File

@@ -9,7 +9,7 @@ CREATED_TAG=""
# ── logging ──────────────────────────────────────────────────────────────── # ── logging ────────────────────────────────────────────────────────────────
log() { echo "[release] $*"; } log() { echo "[release] $*" >&2; }
usage() { usage() {
local cmd local cmd
@@ -194,45 +194,50 @@ 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
local highest_tag="" # and never contaminates the stdout of do_read_version.
while IFS= read -r raw_tag; do init_version_file() {
local tag="${raw_tag#v}" if [[ -f "$ROOT_DIR/VERSION" ]]; then
[[ $tag =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$ ]] || continue return 0
if [[ -z $highest_tag ]]; then
highest_tag="$tag"
continue
fi
local cmp_status=0
version_cmp "$tag" "$highest_tag" || cmp_status=$?
[[ $cmp_status -eq 1 ]] && highest_tag="$tag"
done < <(git tag --list)
[[ -z $highest_tag ]] && highest_tag="0.0.1"
parse_full_version "$highest_tag"
local channel_to_write="$CHANNEL"
local n_to_write="${PRERELEASE_NUM:-1}"
if [[ $channel_to_write == "stable" || -z $channel_to_write ]]; then
channel_to_write="stable"
n_to_write="0"
fi
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"
fi fi
local highest_tag=""
while IFS= read -r raw_tag; do
local tag="${raw_tag#v}"
[[ $tag =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$ ]] || continue
if [[ -z $highest_tag ]]; then
highest_tag="$tag"
continue
fi
local cmp_status=0
version_cmp "$tag" "$highest_tag" || cmp_status=$?
[[ $cmp_status -eq 1 ]] && highest_tag="$tag"
done < <(git tag --list)
[[ -z $highest_tag ]] && highest_tag="0.0.1"
parse_full_version "$highest_tag"
local channel_to_write="$CHANNEL"
local n_to_write="${PRERELEASE_NUM:-1}"
if [[ $channel_to_write == "stable" || -z $channel_to_write ]]; then
channel_to_write="stable"
n_to_write="0"
fi
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"
}
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,8 +270,16 @@ 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)" 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
echo "Error: could not determine current version from VERSION source" >&2
exit 1
fi
parse_full_version "$raw_version" parse_full_version "$raw_version"
log "Current: base=$BASE_VERSION channel=$CHANNEL pre=${PRERELEASE_NUM:-}" log "Current: base=$BASE_VERSION channel=$CHANNEL pre=${PRERELEASE_NUM:-}"

View File

@@ -4,7 +4,7 @@
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
devshell-lib.url = "github:yourorg/devshell-lib"; devshell-lib.url = "git+https://git.dgren.dev/eric/nix-flake-lib";
devshell-lib.inputs.nixpkgs.follows = "nixpkgs"; devshell-lib.inputs.nixpkgs.follows = "nixpkgs";
}; };