1#!/usr/bin/env bash
 2
 3set -eu
 4
 5package=$1
 6tag_prefix=$2
 7tag_suffix=$3
 8version_increment=$4
 9gpui_release=${5:-false}
10
11if [[ -n $(git status --short --untracked-files=no) ]]; then
12  echo "can't bump version with uncommitted changes"
13  exit 1
14fi
15
16which cargo-set-version > /dev/null || cargo install cargo-edit
17which jq > /dev/null || brew install jq
18cargo set-version --package $package --bump $version_increment
19cargo check --quiet
20
21new_version=$(script/get-crate-version $package)
22branch_name=$(git rev-parse --abbrev-ref HEAD)
23old_sha=$(git rev-parse HEAD)
24tag_name=${tag_prefix}${new_version}${tag_suffix}
25
26git commit --quiet --all --message "${package} ${new_version}"
27git tag ${tag_name}
28
29if [[ "$gpui_release" == "true" ]]; then
30cat <<MESSAGE
31Locally committed and tagged ${package} version ${new_version}
32
33To push this:
34
35    git push origin ${tag_name} ${branch_name}; gh pr create -H ${branch_name}
36
37To undo this:
38
39    git branch -D ${branch_name} && git tag -d ${tag_name}
40
41MESSAGE
42else
43cat <<MESSAGE
44Locally committed and tagged ${package} version ${new_version}
45
46To push this:
47
48    git push origin ${tag_name} ${branch_name}
49
50To undo this:
51
52    git reset --hard ${old_sha} && git tag -d ${tag_name}
53
54MESSAGE
55fi