forked from getsentry/sentry-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbump-version
executable file
·51 lines (43 loc) · 1.29 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
set -e
if [ -z "$1" ]; then
set -- "patch"
fi
if [ "$(git diff --shortstat 2> /dev/null | tail -n1)" != "" ]; then
echo "ERROR: There are uncommitted changes in this repository!"
echo "Please commit all changes before tagging a new version."
exit 1
fi
VERSION=$(grep '^version' Cargo.toml | cut -d\" -f2 | head -1)
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)
case $1 in
major)
TARGET="$(($MAJOR + 1)).0.0"
;;
minor)
TARGET="$MAJOR.$(($MINOR + 1)).0"
;;
patch)
TARGET="$MAJOR.$MINOR.$(($PATCH + 1))"
;;
*)
if ! echo "$1" | grep -Eq '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$'; then
echo "Usage: $0 <version | major | minor | patch>"
echo "ERROR: Version must be a valid semver in format 'x.y.z'"
exit 1
fi
TARGET="$1"
;;
esac
echo "Current version: $VERSION"
echo "Bumping version: $TARGET"
sed -i '' -e "1,/^version/ s/^version.*/version = \"$TARGET\"/" Cargo.toml
sed -i '' -e "1,/\"version\"/ s/\"version\".*/\"version\": \"$TARGET\",/" package.json
cargo update -p sentry-cli
git commit -a -m "release: $TARGET" > /dev/null
git tag "$TARGET"
echo
echo "Updated version and tagged release $TARGET, please run:"
echo " git push origin master $TARGET"