generated from Flokkq/git-cliff-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·46 lines (37 loc) · 1.36 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
#!/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 [ -z "$1" ]; then
echo "Please provide a tag."
echo "Usage: ./release.sh v[X.Y.Z]"
exit
fi
echo "Preparing $1..."
msg="# managed by release.sh"
# update the README.md file with the new version tag
if [ -f "README.md" ]; then
echo "Updating README.md with the new version tag..."
sed -i.bak "s/v[0-9]\+\.[0-9]\+\.[0-9]\+/$1/g" README.md
rm README.md.bak
echo "README.md updated!"
else
echo "README.md not found. Skipping version replacement."
fi
# update the changelog
git-cliff --config .cliff/default.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 .cliff/detailed.toml --unreleased --strip all)
git 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)."