#!/usr/bin/env bash # Compute the next release version for alkane-toolkit from the latest release # tag and the paths changed since it. Version scheme X.Y.Z: # X - major, bumped manually (ci/version-x.txt); a bump resets Y.Z to 0.0 # Y - backend-logic changes (the alkane-* crates and any GUI crate source # other than the view files below, plus vendored deps and build/CI config); # resets Z to 0 # Z - UI changes (the GUI view: ui.rs + fixtures.rs + bin/ + the wx-rs bridge) # When both backend and UI changed, backend wins (bump Y). Docs-only changes # produce no release. # # Emits KEY=VALUE lines on stdout (suitable for $GITHUB_OUTPUT): # version, tag, bump, release (true/false), last_tag set -euo pipefail x_file="ci/version-x.txt" X=0 [ -f "$x_file" ] && X=$(tr -dc '0-9' < "$x_file") X=${X:-0} last=$(git tag -l 'v*.*.*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1 || true) if [ -n "$last" ]; then v=${last#v}; lx=${v%%.*}; rest=${v#*.}; ly=${rest%%.*}; lz=${rest##*.} changed=$(git diff --name-only "$last"..HEAD) else lx=0; ly=0; lz=0 changed=$(git ls-files) fi ui=false; backend=false while IFS= read -r f; do [ -z "$f" ] && continue case "$f" in crates/alkane-gui/src/ui.rs|crates/alkane-gui/src/fixtures.rs|thirdparty/wx-rs/*|\ crates/alkane-gui/src/bin/*) ui=true ;; crates/alkane-core/*|crates/alkane-discovery/*|crates/alkane-access/*|\ crates/alkane-flash/*|crates/alkane-artifacts/*|crates/alkane-cli/*|\ crates/alkane-gui/src/*|crates/alkane-gui/Cargo.toml|crates/alkane-gui/build.rs|\ crates/alkane-gui/windows/*|crates/alkane-gui/assets/*|\ Cargo.toml|Cargo.lock|.gitea/*|ci/*|scripts/*|\ vendor/*|thirdparty/asic-rs/*) # Any other GUI source file (naming, scan, model, pool_prefs, restore, # access_probe, credentials, ...) is backend logic, as is how the binary # is built and packaged (build.rs, the Windows manifest/icon/version # resources, embedded assets). ui.rs/fixtures.rs/bin # match the UI arm above first, so they still bump Z, not Y. backend=true ;; *) : ;; # docs, HANDOFF, README, thirdparty/wxwidgets tree: no bump esac done <<< "$changed" if [ -z "$last" ]; then # First release: X.1.0 (or X.0.0 if X was pre-bumped above 0). nx=$X; if [ "$X" -gt 0 ]; then ny=0; else ny=1; fi; nz=0; bump=initial; release=true elif [ "$X" -gt "$lx" ]; then nx=$X; ny=0; nz=0; bump=major; release=true elif [ "$backend" = true ]; then nx=$lx; ny=$((ly + 1)); nz=0; bump=backend; release=true elif [ "$ui" = true ]; then nx=$lx; ny=$ly; nz=$((lz + 1)); bump=ui; release=true else nx=$lx; ny=$ly; nz=$lz; bump=none; release=false fi echo "version=${nx}.${ny}.${nz}" echo "tag=v${nx}.${ny}.${nz}" echo "bump=${bump}" echo "release=${release}" echo "last_tag=${last:-none}"