ci: update release.sh for git-cliff arg changes
This commit is contained in:
parent
97b85b41a4
commit
259b07a949
1 changed files with 32 additions and 32 deletions
64
release.sh
64
release.sh
|
@ -1,47 +1,47 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
git_status=`git status --porcelain`
|
||||
git_status=$(git status --porcelain)
|
||||
if [[ ! -z $git_status ]]; then
|
||||
echo -e "\e[31muncommitted state:\e[0m"
|
||||
git status -s
|
||||
echo -e "\e[31mplease commit or tidy uncommitted state before running release\e[0m"
|
||||
exit
|
||||
echo -e "\e[31muncommitted state:\e[0m"
|
||||
git status -s
|
||||
echo -e "\e[31mplease commit or tidy uncommitted state before running release\e[0m"
|
||||
exit
|
||||
fi
|
||||
|
||||
# takes the tag as an argument (e.g. v0.1.0)
|
||||
if [ -n "$1" ]; then
|
||||
if ! $(echo "${1}"|grep -q '^v[0-9]\+\.[0-9]\+\.[0-9]\+$'); then
|
||||
echo -e "\e[31m${1} not a version of the expected format; please use v#.#.# format\e[0m"
|
||||
exit
|
||||
fi
|
||||
# update the version
|
||||
msg="# managed by release.sh"
|
||||
sed "s/^version = .* $msg$/version = \"${1#v}\" $msg/" -i Cargo.toml
|
||||
# update the changelog
|
||||
git cliff --date-order --sort newest --unreleased --tag "$1" --prepend CHANGELOG.md
|
||||
git diff
|
||||
echo -e -n "\e[33mProceed? \e[0m"
|
||||
read -n 1 -s -p "[y/N] " proceed
|
||||
echo
|
||||
if [[ "${proceed}" != "y" ]]; then
|
||||
echo -e "\e[31maborting; leaving dirty state:\e[0m"
|
||||
git status -s
|
||||
exit
|
||||
fi
|
||||
git add -A
|
||||
git commit -m "chore(release): prepare for $1"
|
||||
git show
|
||||
# generate a changelog for the tag message
|
||||
export GIT_CLIFF_TEMPLATE="\
|
||||
if ! $(echo "${1}" | grep -q '^v[0-9]\+\.[0-9]\+\.[0-9]\+$'); then
|
||||
echo -e "\e[31m${1} not a version of the expected format; please use v#.#.# format\e[0m"
|
||||
exit
|
||||
fi
|
||||
# update the version
|
||||
msg="# managed by release.sh"
|
||||
sed "s/^version = .* $msg$/version = \"${1#v}\" $msg/" -i Cargo.toml
|
||||
# update the changelog
|
||||
git cliff --topo-order --sort newest --unreleased --tag "$1" --prepend CHANGELOG.md
|
||||
git diff
|
||||
echo -e -n "\e[33mProceed? \e[0m"
|
||||
read -n 1 -s -p "[y/N] " proceed
|
||||
echo
|
||||
if [[ "${proceed}" != "y" ]]; then
|
||||
echo -e "\e[31maborting; leaving dirty state:\e[0m"
|
||||
git status -s
|
||||
exit
|
||||
fi
|
||||
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 --date-order --sort newest --unreleased --strip all)
|
||||
git tag "$1" -m "Release $1" -m "$changelog"
|
||||
git show -q "$1"
|
||||
changelog=$(git cliff --topo-order --sort newest --unreleased --strip all)
|
||||
git tag "$1" -m "Release $1" -m "$changelog"
|
||||
git show -q "$1"
|
||||
else
|
||||
echo "warn: please provide a tag"
|
||||
echo "warn: please provide a tag"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue