diff --git a/justfile b/justfile index fb6c094..853e55e 100644 --- a/justfile +++ b/justfile @@ -133,13 +133,24 @@ test-race: bump new: #!/usr/bin/env bash set -euo pipefail - [[ "{{new}}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "Usage: just bump X.Y.Z"; exit 1; } - perl -pi -e 's/^const version = ".*"/const version = "{{new}}"/' {{pkg}}/main.go - perl -pi -e 's/version = ".*"/version = "{{new}}"/' flake.nix - perl -pi -e 's/!define VERSION ".*"/!define VERSION "{{new}}"/' packaging/windows/installer.nsi - perl -pi -e 's|()[^<]*()|${1}{{new}}${2}| if $prev =~ /CFBundle(Version|ShortVersionString)/; $prev = $_' packaging/darwin/Info.plist - echo "Bumped to {{new}}" - grep -n "{{new}}" {{pkg}}/main.go flake.nix packaging/windows/installer.nsi packaging/darwin/Info.plist + current="{{version}}" + new="{{new}}" + case "$new" in + patch|minor|major) + IFS=. read -r current_major current_minor current_patch <<< "$current" + case "$new" in + patch) new="$current_major.$current_minor.$((current_patch + 1))" ;; + minor) new="$current_major.$((current_minor + 1)).0" ;; + major) new="$((current_major + 1)).0.0" ;; + esac ;; + esac + [[ "$new" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "Usage: just bump X.Y.Z|patch|minor|major"; exit 1; } + perl -pi -e "s/^const version = \".*\"/const version = \"$new\"/" {{pkg}}/main.go + perl -pi -e "s/version = \".*\"/version = \"$new\"/" flake.nix + perl -pi -e "s/!define VERSION \".*\"/!define VERSION \"$new\"/" packaging/windows/installer.nsi + perl -pi -e 's|()[^<]*()|${1}'"$new"'${2}| if $prev =~ /CFBundle(Version|ShortVersionString)/; $prev = $_' packaging/darwin/Info.plist + echo "Bumped to $new" + grep -n "$new" {{pkg}}/main.go flake.nix packaging/windows/installer.nsi packaging/darwin/Info.plist clean: rm -rf {{bin}} {{dist}} result