-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·42 lines (32 loc) · 953 Bytes
/
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
#!/usr/bin/env bash
# Exit immediately if a command exits with a non-zero status
set -e
# Function to display usage
usage() {
echo "Usage: $0 <new_version>"
echo "Example: $0 v1.2.3"
exit 1
}
# Check if version argument is provided
if [ -z "$1" ]; then
usage
fi
NEW_VERSION=$1
# Validate the version format (vX.Y.Z)
if [[ ! "$NEW_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version must be in the format vX.Y.Z (e.g., v1.2.3)"
exit 1
fi
# Update the version in pyproject.toml
echo "Updating version in pyproject.toml to $NEW_VERSION"
sed -i.bak "s/^version = \".*\"/version = \"$NEW_VERSION\"/" pyproject.toml
rm pyproject.toml.bak
# Commit the change
git add pyproject.toml
git commit -m "Bump version to $NEW_VERSION"
# Create a new git tag
git tag "$NEW_VERSION"
# Push commit and tag to GitHub
git push origin master
git push origin "$NEW_VERSION"
echo "Released version $NEW_VERSION successfully."