#!/usr/bin/env fish # Release script for fork tags. Computes the next -fork.N tag from the # latest upstream version, has Crush update the README version string # (amending HEAD), pushes the branch, tags, pushes the tag, then # cross-compiles, packs with UPX, and uploads to the releases server. set -l targets \ linux/amd64 \ linux/arm64 \ darwin/amd64 \ darwin/arm64 \ windows/amd64 \ freebsd/amd64 # UPX 5.x dropped macOS support; windows/amd64 is PE32 only and # freebsd/amd64 is ELF32 only, so only Linux targets are packed. set -l pack_targets \ linux-amd64 \ linux-arm64 # --- Guards --- set -l branch (git symbolic-ref --short HEAD) if test "$branch" != dev echo "Error: not on dev branch (on $branch)" >&2 exit 1 end if test (git status --porcelain=2 | wc -l) -ne 0 echo "Error: git working tree is dirty" >&2 exit 1 end # --- Fetch tags --- git tag -d nightly 2>/dev/null; or true git fetch upstream --tags # --- Compute next fork tag --- set -l upstream_version (git tag -l "v*" | sort -V | tail -1; or echo v0.0.0) set -l existing (git tag -l "$upstream_version-fork.*" | wc -l | string trim) set -l next_num (math $existing + 1) set -l tag "$upstream_version-fork.$next_num" # --- Confirm creation --- read -P "Create fork release $tag? [y/N] " confirm if test "$confirm" != y -a "$confirm" != Y echo Aborted. exit 0 end # --- Update README via Crush and amend HEAD --- crush run -m kimi-k2.5h "Please update the mentioned version in the top of the README to $tag. You only need to read the first 65 lines for the relevant bits. If the content is already correct, you don't need to do anything. Amend the commit at HEAD, updating its subject/message if necessary. Use the skill." echo git show --stat HEAD # --- Confirm amended commit --- read -P "Proceed with tagging? [y/N] " confirm if test "$confirm" != y -a "$confirm" != Y echo "Aborting — restoring pre-amend commit." git reset --hard 'HEAD@{1}' exit 0 end # --- Push branch (force because we amended) --- git push --force-with-lease; or begin echo "Error: branch push failed" >&2 exit 1 end # --- Tag and push --- git tag -a $tag; or begin echo "Error: tagging failed" >&2 exit 1 end git push soft $tag; or begin echo "Error: tag push failed — deleting local tag" >&2 git tag -d $tag 2>/dev/null exit 1 end echo "Released $tag" # --- Cross-compile --- set -l ldflags "-s -w -X git.secluded.site/crush/internal/version.Version=$tag" rm -rf dist mkdir -p dist for target in $targets set -l os (echo $target | cut -d/ -f1) set -l arch (echo $target | cut -d/ -f2) set -l ext "" if test "$os" = windows set ext .exe end echo "Building $os/$arch..." env CGO_ENABLED=0 GOEXPERIMENT=greenteagc GOOS=$os GOARCH=$arch \ go build -o "dist/crush-$tag-$os-$arch$ext" -ldflags "$ldflags"; or begin echo "Error: build failed for $os/$arch" >&2 exit 1 end end # --- Pack with UPX --- for suffix in $pack_targets set -l bin "dist/crush-$tag-$suffix" if test -f "$bin" echo "Packing $suffix..." upx -q "$bin" end end # --- Upload --- fish -c "release upload crush $tag --latest dist/*" echo "Done — $tag built, packed, and uploaded."