-
Notifications
You must be signed in to change notification settings - Fork 28
/
prepare_release.sh
executable file
·61 lines (50 loc) · 1.31 KB
/
prepare_release.sh
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
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
#// prepare release
function check_result () {
ret=$?
if [[ $ret != 0 ]];then
echo "early exit due to error!"
exit $ret
fi
}
# get semver of amqprs
version=$(egrep '^version = "(.+)"$' -o amqprs/Cargo.toml | cut -d '"' -f2)
# check semver
semver_regex="[0-9]+\.[0-9]+\.[0-9]+"
if ! [[ $version =~ $semver_regex ]]; then
echo "error, check semantic version: '$version'"
exit 1
fi
# dry run publish check
cargo publish -p amqprs --all-features --dry-run --allow-dirty
check_result
# check contents to be packaged into crate
cargo package --list --allow-dirty
check_result
# check size of crate
ls -hl target/package/amqprs-${version}.crate
check_result
read -p "Are you going to release v${version}? " ans
if [ "$ans" != "y" ]; then
exit 0
fi
read -p 'make a commit? ' ans
if [ "$ans" = "y" ]; then
read -p 'additional commit message: ' message
git commit -a -m "prepare release v${version}. ${message}"
git log -1
fi
read -p 'push commit? ' ans
if [ "$ans" = "y" ]; then
git push
fi
read -p "push tag v${version}? " ans
if [ "$ans" = "y" ]; then
git tag -a "v${version}" -m "v${version}"
git push origin "v${version}"
git log -1
fi
read -p 'Want to publish to crates.io? ' ans
if [ "$ans" = "y" ]; then
cargo publish -p amqprs --all-features
fi