-
Notifications
You must be signed in to change notification settings - Fork 0
/
bump-version
executable file
·34 lines (23 loc) · 1.24 KB
/
bump-version
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
set -eu -o pipefail -o verbose
new_version=$1
# Bail out if working directory is not clean
# https://unix.stackexchange.com/a/394674
git update-index --really-refresh
git diff-index --quiet HEAD
last_line=$(rg ';' schema/exastash_versions.sql | tail -n 1)
current_version_id=$(echo "$last_line" | cut -d , -f 1 | rg -o '[0-9]+')
new_version_id=$(($current_version_id + 1))
echo "$current_version_id -> $new_version_id"
sed -i -r "s/($current_version_id, .+);/\1,\n ($new_version_id, '$new_version');/" schema/exastash_versions.sql
sed -i -r "s/^version = .+/version = \"$new_version\"/" Cargo.toml
sed -i -r "s/^pub const EXASTASH_VERSION: i16 = .+;/pub const EXASTASH_VERSION: i16 = $new_version_id;/" src/lib.rs
sed -i -r "s/^INSERT INTO dirs VALUES \(DEFAULT, now\(\), now\(\), $current_version_id, ''\);/INSERT INTO dirs VALUES (DEFAULT, now(), now(), $new_version_id, '');/" schema/inodes.sql
# Update Cargo.lock
cargo test
# Commit and tag, because without this, we frequently forgot to do it ourselves
git commit -a -m "$new_version"
git tag "$new_version"
echo "Created commit and tag for $new_version. Remember to psql into production and:"
echo
echo "INSERT INTO stash.exastash_versions VALUES ($new_version_id, '$new_version');"