-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·77 lines (63 loc) · 2.42 KB
/
release.sh
File metadata and controls
executable file
·77 lines (63 loc) · 2.42 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
# Original https://github.com/orhun/git-cliff/blob/main/release.sh
set -e
# Update this to archive old changelogs
# NOTE: Make sure to also update cliff.toml:footer to includes those archvied changelogs as well
START_COMMIT="ed944248282e099601ce15b4903fa6345c0b7845"
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 ! command -v semver &>/dev/null; then
echo "semver is required to validate the tag."
fi
version_tag="$1"
if [ -z "$version_tag" ]; then
echo "Please provide a tag."
echo "Usage: ./release.sh v[X.Y.Z]"
exit
fi
if semver valid "$version_tag" > /dev/null; then
echo "Valid SemVer: $version_tag"
else
echo "Invalid SemVer: \"$version_tag\"" >&2
echo "Eg: 0.1.1 0.1.1-dev0"
exit 1
fi
# Define your cleanup or final function
exit_message() {
echo "-----------------"
echo "If you aren't happy with these changes. try again with"
echo "git reset --soft HEAD~1"
echo "git tag -d $version_tag"
}
trap exit_message EXIT
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$BASE_DIR"
echo "Preparing $version_tag..."
# update the version
msg="# managed by release.sh"
sed -E -i "s/^version = .* $msg$/version = \"${version_tag#v}\" $msg/" "./pyproject.toml"
uv sync
git add ./pyproject.toml ./uv.lock
sed -E -i "s/^version: .* $msg$/version: ${version_tag#v}-SET-BY-CICD $msg/" "./helm/Chart.yaml"
git add ./helm/Chart.yaml
# update the changelog
git-cliff "$START_COMMIT..HEAD" --config cliff.toml --tag "$version_tag" > CHANGELOG.md
git add CHANGELOG.md
git commit -m "chore(release): prepare for $version_tag"
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 "$START_COMMIT..HEAD" --config detailed.toml --unreleased --strip all)
# create a signed tag
# https://keyserver.ubuntu.com/pks/lookup?search=0x4A92FA17B6619297&op=vindex
git tag "$version_tag" -m "Release $version_tag" -m "$changelog"
git tag -v "$version_tag"
echo "Done!"
echo "Now push the commit (git push) and the tag (git push --tags)."