Skip to content

Commit

Permalink
Enforce release version only in setversion.sh and update commit messa…
Browse files Browse the repository at this point in the history
…ges for versioning
  • Loading branch information
mkjsix committed Nov 4, 2024
1 parent 7324ea6 commit 77c79c8
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions setversion.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
#!/bin/bash
if [ -z "$1" ]
then
cat << EOF

if [ -z "$1" ]; then
cat <<EOF
This script is used to set the version of the project.
It also commits the change and creates a tag if the version is not a SNAPSHOT.
To create a new stable release of RESTHeart, for example 7.3.4:
It only accepts release versions (not SNAPSHOT versions).
To create a new stable release of RESTHeart, for example 8.2.0:
$ ./setversion.sh 7.3.4
$ ./setversion.sh 7.3.5-SNAPSHOT
$ git push && git push --tags
$ ./setversion.sh 8.2.0
# This will automatically create a new release version and set the next version as a SNAPSHOT.
EOF
exit 1
exit 1
fi

# Enforce release version only (do not allow "SNAPSHOT" in the version)
if [[ "$1" == *SNAPSHOT* ]]; then
echo "Error: SNAPSHOT versions are not allowed. Please provide a release version (e.g., 8.1.4)." >&2
exit 1
fi

set -Eeuo pipefail

# Set the release version
mvn versions:set -DnewVersion="$1"

if [[ "$1" == *SNAPSHOT ]]
then
echo "This is a SNAPSHOT";
git commit -am "Bump version to $1 [skip ci]"
else
echo "This is a Release";
git commit -am "Release version $1"
git tag "$1"
fi
# Commit and tag the release version
echo "This is a Release"
git commit -am "Release version $1"
git tag "$1"

# Set the new version to SNAPSHOT (e.g., if input is 8.1.4, set version to 8.1.4-SNAPSHOT)
SNAPSHOT_VERSION="${1}-SNAPSHOT"
mvn versions:set -DnewVersion="$SNAPSHOT_VERSION"

# Commit the SNAPSHOT version
git commit -am "Bump version to $SNAPSHOT_VERSION [skip ci]"

0 comments on commit 77c79c8

Please sign in to comment.