File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 99
1010VERSION_TYPE=$1
1111
12+ # Store the original version before any changes
13+ ORIGINAL_VERSION=$( poetry version -s)
14+
15+ # Function to rollback changes
16+ rollback () {
17+ echo " Error occurred. Rolling back changes..."
18+ # Reset version in pyproject.toml
19+ poetry version " $ORIGINAL_VERSION "
20+ # Remove local tag if it exists
21+ if git tag | grep -q " v${NEW_VERSION} " ; then
22+ git tag -d " v${NEW_VERSION} "
23+ fi
24+ # Reset any changes in git
25+ git reset --hard HEAD^
26+ echo " Rollback complete. Version restored to ${ORIGINAL_VERSION} "
27+ exit 1
28+ }
29+
30+ # Set up trap to catch errors
31+ trap rollback ERR
32+
1233# Ensure we're on main branch
1334current_branch=$( git branch --show-current)
1435if [ " $current_branch " != " main" ]; then
@@ -50,3 +71,6 @@ gh release create "v${NEW_VERSION}" \
5071 --generate-notes
5172
5273echo " Released v${NEW_VERSION} successfully!"
74+
75+ # Remove the trap since we succeeded
76+ trap - ERR
You can’t perform that action at this time.
0 commit comments