-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
6 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script is used to tag and push a new version of the project | ||
# It is intended to be run from the root of the project | ||
# It uses the git tag command to create a new tag and push it to the remote repository | ||
# Tag and push a new version of the project from the root directory | ||
|
||
# Ensure the script is run from the root of the project | ||
if [ ! -f "pom.xml" ]; then | ||
echo "This script must be run from the root of the project where the pom.xml file is located." | ||
exit 1 | ||
fi | ||
[ -f "pom.xml" ] || { echo "Run from the project root with pom.xml"; exit 1; } | ||
|
||
# Ensure the working directory is clean | ||
if [ -n "$(git status --porcelain)" ]; then | ||
echo "Working directory is not clean. Please commit or stash your changes." | ||
exit 1 | ||
fi | ||
[ -z "$(git status --porcelain)" ] || { echo "Working directory is not clean, please commit or stash your changes"; exit 1; } | ||
|
||
# Ensure current POM version is a valid semver | ||
if ! mvn semver:verify-current; then | ||
echo "Current POM version is not a valid semver version." | ||
exit 1 | ||
fi | ||
mvn semver:verify-current >/dev/null || { echo "Current POM version is not a valid semver version"; exit 1; } | ||
|
||
# Get the current version from the pom.xml file | ||
CURRENT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout | tr -d "[:space:]") | ||
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | tr -d "[:space:]") | ||
|
||
# Create a new tag with the current version | ||
# Create and push a new tag with the current version | ||
git tag -a "$CURRENT_VERSION" -m "Release version tag $CURRENT_VERSION" | ||
|
||
# Push the new tag to the remote repository | ||
git push origin "$CURRENT_VERSION" | ||
|
||
echo "Tagged and pushed version $CURRENT_VERSION." |