Skip to content

Instantly share code, notes, and snippets.

@ArtDepartmentMJ
Last active April 30, 2026 09:45
Show Gist options
  • Select an option

  • Save ArtDepartmentMJ/3c6e324b461c9c91a1f8b076567afc4f to your computer and use it in GitHub Desktop.

Select an option

Save ArtDepartmentMJ/3c6e324b461c9c91a1f8b076567afc4f to your computer and use it in GitHub Desktop.
zsh/bash release function
release() {
local root script url local_version remote_version
root="$(git rev-parse --show-toplevel 2>/dev/null)"
if [[ -z "$root" ]]; then
echo "Not inside a git repository."
return 1
fi
script="$root/scripts/release.mjs"
url="https://gist.githubusercontent.com/ArtDepartmentMJ/04da069c9df36a6db8e81a203f8460c5/raw/gistfile1.txt"
if [[ ! -f "$script" ]]; then
echo "No scripts/release.mjs found in this repo."
read "reply?Download from GitHub? [y/N] "
if [[ "$reply" =~ ^[Yy]$ ]]; then
mkdir -p "$root/scripts"
if curl -fsSL "$url" -o "$script"; then
echo "Downloaded to $script"
else
echo "Download failed. Check the URL in your ~/.zshrc."
return 1
fi
else
return 1
fi
else
local_version=$(grep -m1 "^const VERSION" "$script" | grep -o "'[^']*'" | tr -d "'")
remote_version=$(curl -fsSL "$url" 2>/dev/null | grep -m1 "^const VERSION" | grep -o "'[^']*'" | tr -d "'")
if [[ -n "$remote_version" && "$remote_version" != "$local_version" ]]; then
echo "Update available: $local_version → $remote_version"
read "reply?Update? [y/N] "
if [[ "$reply" =~ ^[Yy]$ ]]; then
curl -fsSL "$url" -o "$script" && echo "Updated to $remote_version"
fi
fi
fi
node "$script"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment