forked from dtn7/bp7-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·48 lines (44 loc) · 1.23 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
#!/usr/bin/env bash
# takes the tag as an argument (e.g. v0.1.0)
if [ -n "$1" ]; then
# update the version
msg="# managed by release.sh"
# on macos use gsed instead of set
if [ "$(uname)" == "Darwin" ]; then
sed="gsed"
else
sed="sed"
fi
$sed "s/^version = .* $msg$/version = \"${1#v}\" $msg/" -i Cargo.toml
# update the changelog
git cliff --tag "$1" > CHANGELOG.md
git add -A && git commit -m "chore(release): prepare for $1"
git show
# generate a changelog for the tag message
export TEMPLATE="\
{% for group, commits in commits | group_by(attribute=\"group\") %}
{{ group | upper_first }}\
{% for commit in commits %}
- {{ commit.message | upper_first }} ({{ commit.id | truncate(length=7, end=\"\") }})\
{% endfor %}
{% endfor %}"
changelog=$(git cliff --unreleased --strip all)
git tag -a "$1" -m "Release $1" -m "$changelog"
read -p "Directly push to GitHub? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
git push
git push origin "$1"
else
echo "Don't forget to push tag to origin: "
echo git push
echo git push origin "$1"
fi
else
echo Changes since last release:
git cliff --unreleased --strip all
echo
echo
echo "warn: please provide a tag"
fi