Skip to content

Commit 2d40021

Browse files
committed
release script
1 parent b5c1dcb commit 2d40021

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

scripts/release.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@ fi
99

1010
VERSION_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
1334
current_branch=$(git branch --show-current)
1435
if [ "$current_branch" != "main" ]; then
@@ -50,3 +71,6 @@ gh release create "v${NEW_VERSION}" \
5071
--generate-notes
5172

5273
echo "Released v${NEW_VERSION} successfully!"
74+
75+
# Remove the trap since we succeeded
76+
trap - ERR

0 commit comments

Comments
 (0)