bump-version.sh

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