2021-06-16 22:43:45 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-01-08 22:55:15 +03:00
|
|
|
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"
|
2023-01-09 17:12:22 +03:00
|
|
|
sed -E -i "s/^version = .* $msg$/version = \"${1#v}\" $msg/" git-cliff*/Cargo.toml
|
|
|
|
sed -E -i "s/\"version\": \".+\"/\"version\": \"${1#v}\"/" npm/git-cliff/package.json
|
|
|
|
sed -E -i "s/\"(git-cliff-.+)\": \".+\"/\"\1\": \"${1#v}\"/g" npm/git-cliff/package.json
|
2023-01-08 22:55:15 +03:00
|
|
|
# update the changelog
|
2023-01-09 17:12:22 +03:00
|
|
|
sed -E -i "s/\s+\#\s(.*)\s\#\sreplace issue numbers/\\t\1/g" config/cliff.toml
|
2023-01-08 22:55:15 +03:00
|
|
|
cargo run -- --tag "$1" >CHANGELOG.md
|
|
|
|
git restore config/cliff.toml
|
|
|
|
git add -A && git commit -m "chore(release): prepare for $1"
|
|
|
|
git show
|
|
|
|
# generate a changelog for the tag message
|
|
|
|
export GIT_CLIFF_TEMPLATE="\
|
2021-06-20 17:08:52 +03:00
|
|
|
{% for group, commits in commits | group_by(attribute=\"group\") %}
|
|
|
|
{{ group | upper_first }}\
|
|
|
|
{% for commit in commits %}
|
2021-12-11 15:20:29 +03:00
|
|
|
- {% if commit.breaking %}(breaking) {% endif %}{{ commit.message | upper_first }} ({{ commit.id | truncate(length=7, end=\"\") }})\
|
2021-06-20 17:08:52 +03:00
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}"
|
2023-01-08 22:55:15 +03:00
|
|
|
changelog=$(cargo run -- --config examples/detailed.toml --unreleased --strip all)
|
|
|
|
# create a signed tag
|
|
|
|
# https://keyserver.ubuntu.com/pks/lookup?search=0x4A92FA17B6619297&op=vindex
|
|
|
|
git -c user.name="git-cliff" \
|
|
|
|
-c user.email="git-cliff@protonmail.com" \
|
|
|
|
-c user.signingkey="1D2D410A741137EBC544826F4A92FA17B6619297" \
|
|
|
|
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)."
|