2021-06-16 22:43:45 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-06-20 17:08:52 +03:00
|
|
|
# takes the tag as an argument (e.g. v0.1.0)
|
2021-06-16 22:43:45 +03:00
|
|
|
if [ -n "$1" ]; then
|
2021-06-30 01:26:32 +03:00
|
|
|
# update the version
|
|
|
|
sed "0,/^version = .*$/s//version = \"${1#v}\"/" -i git-cliff*/Cargo.toml
|
2021-06-20 17:08:52 +03:00
|
|
|
# update the changelog
|
2021-06-16 22:52:08 +03:00
|
|
|
cargo run -- --tag "$1" > CHANGELOG.md
|
2021-06-16 22:43:45 +03:00
|
|
|
git add -A && git commit -m "chore(release): prepare for $1"
|
2021-06-20 17:08:52 +03:00
|
|
|
# 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 %}
|
2021-06-22 00:12:16 +03:00
|
|
|
- {{ commit.message | upper_first }} ({{ commit.id | truncate(length=8, end=\"\") }})\
|
2021-06-20 17:08:52 +03:00
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}"
|
2021-06-16 23:07:00 +03:00
|
|
|
changelog=$(cargo run -- --unreleased --strip all)
|
2021-06-29 20:44:46 +03:00
|
|
|
# create a signed tag
|
|
|
|
# https://keyserver.ubuntu.com/pks/lookup?search=0x4A92FA17B6619297&op=vindex
|
2021-06-20 21:33:22 +03:00
|
|
|
git -c user.name="git-cliff" \
|
|
|
|
-c user.email="git-cliff@protonmail.com" \
|
|
|
|
-c user.signingkey="1D2D410A741137EBC544826F4A92FA17B6619297" \
|
2021-06-19 23:51:44 +03:00
|
|
|
tag -s -a "$1" -m "Release $1" -m "$changelog"
|
2021-06-20 17:08:52 +03:00
|
|
|
else
|
|
|
|
echo "warn: please provide a tag"
|
2021-06-16 22:43:45 +03:00
|
|
|
fi
|