-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrelease.sh
executable file
·40 lines (34 loc) · 1.41 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
#!/usr/bin/env bash
# inspired by https://github.com/orhun/git-cliff/blob/main/release.sh
new_version=$(git cliff --bumped-version)
if [ -z "$new_version" ]; then
echo "No new version found (did git cliff fail?). Exiting."
exit 1
fi
echo "New version: $new_version"
# update package.yaml version
sed -i'' -e "s/^version: \"[^\"]*\"$/version: \"${new_version#v}\"/" package.yaml || exit 1
# and the cabal file
hpack || exit 1
# Update changelog
git cliff --tag "${new_version}" > CHANGELOG.md
git add -A && git commit -m "chore(release): prepare for ${new_version}"
git show || exit 1
read -p "Is this ok? " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
fi
# 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 -c cliff-release.toml --unreleased --strip all)
git tag -s -a "${new_version}" -m "Release ${new_version}" -m "${changelog}"
git tag -v "${new_version}"
echo "Release ready. Run 'git push --follow-tags' to push the changes and tags."