-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-release
executable file
·41 lines (30 loc) · 1.16 KB
/
make-release
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
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
if [ "$#" -ne 1 ]; then
echo "You must pass the version to be released"
exit 1
fi
RELEASE_VERSION="$1"
MINOR_VERSION=$(echo "$RELEASE_VERSION" | sed 's/^.*\.\(.*\)\..*$/\1/g')
NEXT_MINOR_VERSION=$((MINOR_VERSION + 1))
MAJOR_VERSION=$(echo "$RELEASE_VERSION" | sed 's/^\(.*\)\..*\..*$/\1/g')
NEXT_SNAPSHOT_VERSION="$MAJOR_VERSION.$NEXT_MINOR_VERSION.0-SNAPSHOT"
update_cargo() {
local path="$1"
local version="$2"
sed "s/^version = \".*\"$/version = \"$version\"/g" <"$path" >tmp
mv tmp "$path"
}
update_cargo "main/Cargo.toml" "$RELEASE_VERSION"
update_cargo "protocol/Cargo.toml" "$RELEASE_VERSION"
update_cargo "common/Cargo.toml" "$RELEASE_VERSION"
git add {main,protocol,common}/Cargo.toml
git commit -m "Bump version to $RELEASE_VERSION"
git tag -a "$RELEASE_VERSION" -m "Release $RELEASE_VERSION"
update_cargo "main/Cargo.toml" "$NEXT_SNAPSHOT_VERSION"
update_cargo "protocol/Cargo.toml" "$NEXT_SNAPSHOT_VERSION"
update_cargo "common/Cargo.toml" "$NEXT_SNAPSHOT_VERSION"
git add {main,protocol,common}/Cargo.toml
git commit -m "Bump version to $NEXT_SNAPSHOT_VERSION"
git push origin HEAD
git push --tags