Skip to content
Snippets Groups Projects
Commit 06e79394 authored by Jan Zickermann's avatar Jan Zickermann
Browse files

Add release script

parent b6397b3d
Branches
Tags
No related merge requests found
Pipeline #1704 passed
out/
# ---> Maven
target/
pom.xml.tag
......
#!/bin/bash
set -e
# Change directory to the root of the project
cd "$(dirname "${BASH_SOURCE[0]}")/../"
if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]
then
echo "[ERROR] Not on main branch"
exit 1
fi
if [ -n "$(git status --porcelain)" ]
then
echo "[ERROR] Working directory is not clean"
exit 1
fi
MAVEN_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
if [[ ! "$MAVEN_VERSION" =~ -SNAPSHOT$ ]]
then
echo "[ERROR] Version should end with -SNAPSHOT"
exit 1
fi
prompt_yes_no() {
read -p "$1 (y/n) " -n 1 -r
echo
[[ $REPLY =~ ^[Yy]$ ]] || exit 1
}
NUMERIC_VERSION=$(echo "$MAVEN_VERSION" | cut -d'-' -f1)
MAJOR=$(echo "$NUMERIC_VERSION" | cut -d '.' -f 1)
MINOR=$(echo "$NUMERIC_VERSION" | cut -d '.' -f 2)
PATCH=$(echo "$NUMERIC_VERSION" | cut -d '.' -f 3)
CURRENT_VERSION="$MAJOR.$MINOR.$PATCH"
NEW_VERSION="$MAJOR.$((MINOR + 1)).0"
NEW_SNAPSHOT_VERSION="$NEW_VERSION-SNAPSHOT"
prompt_yes_no "Tag $CURRENT_VERSION and bump version from $MAVEN_VERSION to $NEW_SNAPSHOT_VERSION?"
git tag -m "Release version $CURRENT_VERSION" "$CURRENT_VERSION"
mvn versions:set -DnewVersion="$NEW_SNAPSHOT_VERSION" -DgenerateBackupPoms=false
git add -u
git commit -m "Start development of $NEW_VERSION"
prompt_yes_no "git push origin main $CURRENT_VERSION?"
git push origin main "$CURRENT_VERSION"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment