-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrelease.sh
executable file
·84 lines (60 loc) · 1.95 KB
/
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
set -e
cd $(dirname "$0")
cd "$(git rev-parse --show-toplevel)"
source "tools/utils.sh"
function set_version {
local version=$1
sed -i "0,/version = .*$/s//version = \"$version\"/" Cargo.toml
# Update version in `Cargo.lock`.
cargo update -p $(project_name) --offline
}
if [ $(git symbolic-ref --short HEAD) != master ]; then
echo "Not in master branch." >&2
exit 1
fi
if [ $(git status --porcelain | wc -l) -ne 0 ]; then
echo "Working directory is not clean." >&2
exit 1
fi
echo "Current version is $(project_version)."
echo -n "Which version do you want to release? "
read release_version
if ! grep "^## " release-notes.md | head -1 | grep --silent "^## $release_version$"; then
echo "You forgot to update the release notes." >&2
exit 1
fi
echo -n "Which will be the next version? "
read next_version
if ! echo "$next_version" | grep --silent -- "-pre$"; then
echo 'Next version must end in `-pre`.' >&2
fi
echo
echo "Current version: $(project_version)"
echo "Release version: $release_version"
echo "Next version: $next_version"
echo
echo -n 'Does this look right [yes/no]? '
read answer
if [ "$answer" != "yes" ]; then
exit 0
fi
echo -n "Running tests... "
if ! ./tools/check.sh 2>/dev/null > /dev/null; then
echo "It failed :(" >&2
exit 0
fi
echo "done."
set_version "$release_version"
git commit -am "Release v${release_version}."
git tag --sign -a "v${release_version}" -m "$(project_name) version ${release_version}."
set_version "$next_version"
git commit -am "Bump to version $next_version."
echo "Check if everything is alright. If so do:"
echo
echo " git push --atomic origin master v${release_version} && git checkout \"v${release_version}\" && cargo publish && git checkout master"
echo