parent
33298dfb0f
commit
a30e0ec119
2 changed files with 39 additions and 43 deletions
|
@ -38,8 +38,45 @@ jobs:
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Update version
|
- name: Update version
|
||||||
run: |
|
run: |
|
||||||
chmod +x update-version.sh
|
set -e
|
||||||
./update-version.sh
|
|
||||||
|
# Extract version using grep/sed as fallback (works even with -SNAPSHOT)
|
||||||
|
current_version=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" pom.xml)
|
||||||
|
|
||||||
|
if [[ -z "$current_version" ]]; then
|
||||||
|
echo "❌ Failed to extract version from pom.xml"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Strip "-SNAPSHOT" if present
|
||||||
|
base_version="${current_version%-SNAPSHOT}"
|
||||||
|
|
||||||
|
# Split into major.minor.patch
|
||||||
|
IFS='.' read -r major minor patch <<< "$base_version"
|
||||||
|
|
||||||
|
# Handle missing patch (e.g. 1.0)
|
||||||
|
patch=${patch:-0}
|
||||||
|
|
||||||
|
# Increment minor, reset patch
|
||||||
|
minor=$((minor + 1))
|
||||||
|
patch=0
|
||||||
|
|
||||||
|
# Preserve -SNAPSHOT if it was present
|
||||||
|
if [[ "$current_version" == *-SNAPSHOT ]]; then
|
||||||
|
new_version="${major}.${minor}.${patch}-SNAPSHOT"
|
||||||
|
else
|
||||||
|
new_version="${major}.${minor}.${patch}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Apply it with Maven
|
||||||
|
echo "🔧 Updating version: $current_version → $new_version"
|
||||||
|
mvn versions:set -DnewVersion="$new_version"
|
||||||
|
mvn versions:commit
|
||||||
|
|
||||||
|
# Remove unnecessary backup file
|
||||||
|
rm -f pom.xml.versionsBackup
|
||||||
|
|
||||||
|
echo "✅ Done!"
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Extract version using grep/sed as fallback (works even with -SNAPSHOT)
|
|
||||||
current_version=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" pom.xml)
|
|
||||||
|
|
||||||
if [[ -z "$current_version" ]]; then
|
|
||||||
echo "❌ Failed to extract version from pom.xml"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Strip "-SNAPSHOT" if present
|
|
||||||
base_version="${current_version%-SNAPSHOT}"
|
|
||||||
|
|
||||||
# Split into major.minor.patch
|
|
||||||
IFS='.' read -r major minor patch <<< "$base_version"
|
|
||||||
|
|
||||||
# Handle missing patch (e.g. 1.0)
|
|
||||||
patch=${patch:-0}
|
|
||||||
|
|
||||||
# Increment minor, reset patch
|
|
||||||
minor=$((minor + 1))
|
|
||||||
patch=0
|
|
||||||
|
|
||||||
# Preserve -SNAPSHOT if it was present
|
|
||||||
if [[ "$current_version" == *-SNAPSHOT ]]; then
|
|
||||||
new_version="${major}.${minor}.${patch}-SNAPSHOT"
|
|
||||||
else
|
|
||||||
new_version="${major}.${minor}.${patch}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Apply it with Maven
|
|
||||||
echo "🔧 Updating version: $current_version → $new_version"
|
|
||||||
mvn versions:set -DnewVersion="$new_version"
|
|
||||||
mvn versions:commit
|
|
||||||
|
|
||||||
# Remove unnecessary backup file
|
|
||||||
rm -f pom.xml.versionsBackup
|
|
||||||
|
|
||||||
echo "✅ Done!"
|
|
Loading…
Reference in a new issue