Skip to content

Commit 808584a

Browse files
add pre and post commit hooks for bumpver
1 parent b33d3f8 commit 808584a

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

.bin/bumpver-post.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
update_changelog() {
6+
local repo_url
7+
repo_url=$(git remote get-url origin | tr -d '\n' | sed 's/\.git$//')
8+
9+
sed -i "0,/## \[Unreleased\]/s/## \[Unreleased\]/## [$BUMPVER_NEW_VERSION]/" CHANGELOG.md
10+
sed -i "/## \[$BUMPVER_NEW_VERSION\]/i ## [Unreleased]\n" CHANGELOG.md
11+
echo "[$BUMPVER_NEW_VERSION]: $repo_url/releases/tag/v$BUMPVER_NEW_VERSION" >>CHANGELOG.md
12+
sed -i "s|\[unreleased\]: .*|[unreleased]: $repo_url/compare/v$BUMPVER_NEW_VERSION...HEAD|" CHANGELOG.md
13+
14+
git add CHANGELOG.md
15+
git commit -m "update CHANGELOG for version $BUMPVER_NEW_VERSION"
16+
}
17+
18+
update_uvlock() {
19+
uv lock
20+
21+
if ! git status --porcelain | grep -q "uv.lock"; then
22+
echo "No changes to uv.lock, skipping commit"
23+
return 0
24+
fi
25+
26+
git add uv.lock
27+
git commit -m "update uv.lock for version $BUMPVER_NEW_VERSION"
28+
}
29+
30+
main() {
31+
update_changelog
32+
update_uvlock
33+
}
34+
35+
main "$@"

.bin/bumpver-pre.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
create_release_branch() {
6+
local release_branch="release-v${BUMPVER_NEW_VERSION}"
7+
8+
if git show-ref --quiet "refs/heads/$release_branch" ||
9+
git show-ref --quiet "refs/remotes/origin/$release_branch"; then
10+
echo "Error: Branch $release_branch already exists locally or remotely" >&2
11+
exit 1
12+
fi
13+
14+
git checkout -b "$release_branch"
15+
echo "Created and switched to branch: $release_branch"
16+
}
17+
18+
main() {
19+
create_release_branch
20+
}
21+
22+
main "$@"

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ Source = "https://github.com/joshuadavidthomas/django-language-server"
5656
commit = true
5757
commit_message = ":bookmark: bump version {old_version} -> {new_version}"
5858
current_version = "5.1.0-alpha.1"
59-
push = false # set to false for CI
59+
post_commit_hook = ".bin/bumpver-post.sh"
60+
pre_commit_hook = ".bin/bumpver-pre.sh"
61+
push = false
6062
tag = false
6163
version_pattern = "MAJOR.MINOR.PATCH[-TAG[.NUM]]"
6264

0 commit comments

Comments
 (0)