-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake_release.sh
executable file
·58 lines (46 loc) · 1.33 KB
/
make_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
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# Function to display usage information
usage() {
echo "Usage: $0 [patch|minor|major]"
echo " patch: Increment the patch version (0.0.X)"
echo " minor: Increment the minor version (0.X.0)"
echo " major: Increment the major version (X.0.0)"
exit 1
}
# Check if a version increment type is provided
if [ $# -eq 0 ]; then
usage
fi
# Validate the input
case $1 in
patch|minor|major) ;;
*) usage ;;
esac
# Ensure we're on the main branch
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$current_branch" != "main" ]; then
echo "Error: You must be on the main branch to create a release."
exit 1
fi
# Ensure the working directory is clean
if [ -n "$(git status --porcelain)" ]; then
echo "Error: Working directory is not clean. Please commit or stash your changes."
exit 1
fi
# Pull the latest changes
echo "Pulling latest changes..."
git pull origin main
# Bump the version
echo "Bumping $1 version..."
poetry version $1
# Get the new version
new_version=$(poetry version -s)
# Add pyproject.toml to git
git add pyproject.toml
# Commit the change
git commit -m "Release: Bump version to $new_version"
# Push the commit
echo "Pushing changes..."
git push origin main
echo "Release $new_version prepared and pushed."
echo "The CI/CD pipeline will create the release if configured correctly."