-
Notifications
You must be signed in to change notification settings - Fork 1
/
release
executable file
·41 lines (32 loc) · 1.27 KB
/
release
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
#!/usr/bin/env bash
# Check if the git working tree is clean
if [[ -n $(git status --porcelain) ]]; then
echo "Error: Working tree is not clean. Please commit or stash your changes."
exit 1
fi
# Print current tag and ask for new tag
current_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "Current tag: $current_tag"
read -p "Enter the new tag (without the \"v\"): " new_tag
# Validate the new tag format
if [[ ! $new_tag =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Tag must be in the format x.y.z"
exit 1
fi
# Update CHANGELOG
git cliff -c cliff.toml -u -t "v$new_tag" -p CHANGELOG.md
# Update versions
sed -i -E "s/^version = \"[0-9]+\.[0-9]+\.[0-9]+\"/version = \"$new_tag\"/" Cargo.toml
sed -i -E "s/^version = \"[0-9]+\.[0-9]+\.[0-9]+\"/version = \"$new_tag\"/" poke-engine-py/Cargo.toml
sed -i -E "s/^version = \"[0-9]+\.[0-9]+\.[0-9]+\"/version = \"$new_tag\"/" poke-engine-py/pyproject.toml
# Force Cargo.lock to update
cargo update -w
# Prefix the tag with 'v'
new_tag="v$new_tag"
# Commit, tag, and push
git add Cargo* poke-engine-py/Cargo.toml poke-engine-py/pyproject.toml CHANGELOG.md
git commit -m "$new_tag"
git show
git tag -a "$new_tag" -m "$new_tag"
echo "Done! Tagged $new_tag"
echo "Verify the commit and push (git push origin main --tags)"