-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·47 lines (39 loc) · 1.62 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
#!/usr/bin/env bash
if ! command -v typos &>/dev/null; then
echo "typos is not installed. Run 'cargo install typos-cli' to install it, otherwise the typos won't be fixed"
fi
if ! command -v git-cliff &>/dev/null; then
echo "git-cliff is not installed. Run 'cargo install git-cliff' to install it, otherwise the CHANGELOG.md won't be updated"
fi
if [ -z "$1" ]; then
echo "Please provide a tag."
echo "Usage: ./release.sh v[X.Y.Z]"
exit
fi
echo "Preparing $1..."
# update the version
msg="# managed by release.sh"
sed -E -i "s/^version = .* $msg$/version = \"${1#v}\" $msg/" barkit*/Cargo.toml
sed -E -i "s/^version = .* $msg$/version = \"${1#v}\" $msg/" Cargo.toml
sed -E -i "s/(barkit-extract = \{ version = \")[^\"]+/\1${1#v}/" Cargo.toml
# update the changelog
git cliff --config cliff.toml --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 GIT_CLIFF_TEMPLATE="\
{% for group, commits in commits | group_by(attribute=\"group\") %}
{{ group | upper_first }}\
{% for commit in commits %}
- {% if commit.breaking %}(breaking) {% endif %}{{ commit.message | upper_first }} ({{ commit.id | truncate(length=7, end=\"\") }})\
{% endfor %}
{% endfor %}"
changelog=$(git cliff --config examples/detailed.toml --unreleased --strip all)
# create a signed tag
git -c user.name="barkit" \
-c user.email="[email protected]" \
-c user.signingkey="61C056A107882D500B82BA561094E39B2BF14539" \
tag -s -a "$1" -m "Release $1" -m "$changelog"
git tag -v "$1"
echo "Done!"
echo "Now push the commit (git push) and the tag (git push --tags)."