-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathcleanup-failed-release.sh
More file actions
executable file
·68 lines (59 loc) · 2.04 KB
/
cleanup-failed-release.sh
File metadata and controls
executable file
·68 lines (59 loc) · 2.04 KB
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
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Cleanup script for failed maven releases
set -e
echo "=== Cleaning up failed release artifacts ==="
echo
# Get current version from pom.xml
CURRENT_VERSION=$(grep -m 1 "<version>" pom.xml | sed 's/.*<version>\(.*\)-SNAPSHOT<\/version>.*/\1/')
VERSION_TAG="sparkey-$CURRENT_VERSION"
echo "Current version: $CURRENT_VERSION"
echo "Expected tag: $VERSION_TAG"
echo
# 1. Delete release files
echo "1. Cleaning up release files..."
if [ -f release.properties ] || [ -f pom.xml.releaseBackup ]; then
rm -f release.properties pom.xml.releaseBackup
echo " ✓ Deleted release.properties and pom.xml.releaseBackup"
else
echo " ✓ No release files to clean"
fi
echo
# 2. Delete local tag
echo "2. Checking for local tag..."
if git tag | grep -q "^$VERSION_TAG\$"; then
git tag -d "$VERSION_TAG"
echo " ✓ Deleted local tag: $VERSION_TAG"
else
echo " ✓ No local tag to delete"
fi
echo
# 3. Check for remote tag
echo "3. Checking for remote tag..."
if git ls-remote --tags origin | grep -q "refs/tags/$VERSION_TAG\$"; then
echo " ⚠ Remote tag exists: $VERSION_TAG"
read -p " Delete remote tag? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
git push --delete origin "$VERSION_TAG"
echo " ✓ Deleted remote tag: $VERSION_TAG"
else
echo " ⚠ Remote tag NOT deleted (you can delete it later with: git push --delete origin $VERSION_TAG)"
fi
else
echo " ✓ No remote tag to delete"
fi
echo
# 4. Reset pom.xml if needed
echo "4. Checking pom.xml version..."
POM_VERSION=$(grep -m 1 "<version>" pom.xml | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
if [[ "$POM_VERSION" != *"-SNAPSHOT" ]]; then
echo " ⚠ WARNING: pom.xml version is $POM_VERSION (not a SNAPSHOT)"
echo " You may need to manually reset to $CURRENT_VERSION-SNAPSHOT"
echo " Or run: mvn release:rollback"
else
echo " ✓ pom.xml version is correct: $POM_VERSION"
fi
echo
echo "=== Cleanup complete ==="
echo
echo "Run ./verify-release-ready.sh to check if everything is ready for release"