2020-03-10 16:48:39 -05:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
GIT_RELEASE_BOT_NAME=${GIT_RELEASE_BOT_NAME:?GIT_RELEASE_BOT_NAME must be provided}
|
|
|
|
GITHUB_SHA=${GITHUB_SHA:?GITHUB_SHA must be provided}
|
|
|
|
GITHUB_REF=${GITHUB_REF:?GITHUB_REF must be provided}
|
|
|
|
RELEASE_BRANCH_NAME=${RELEASE_BRANCH_NAME:?RELEASE_BRANCH_NAME must be provided}
|
|
|
|
#MAVEN_LOCAL_REPO_PATH=${MAVEN_LOCAL_REPO_PATH:?MAVEN_LOCAL_REPO_PATH must be provided}
|
|
|
|
#MAVEN_REPO_LOCAL=${MAVEN_REPO_LOCAL:?MAVEN_REPO_LOCAL must be provided}
|
|
|
|
#MAVEN_ARGS=${MAVEN_ARGS:?MAVEN_ARGS must be provided}
|
|
|
|
|
|
|
|
# avoid the release loop by checking if the latest commit is a release commit
|
2020-03-12 15:41:23 -05:00
|
|
|
readonly local last_release_commit_hash=$(git log --pretty=format:"%H" -1)
|
2020-03-10 16:48:39 -05:00
|
|
|
echo "Last $GIT_RELEASE_BOT_NAME commit: ${last_release_commit_hash}"
|
|
|
|
echo "Current commit: ${GITHUB_SHA}"
|
|
|
|
if [[ "${last_release_commit_hash}" = "${GITHUB_SHA}" ]]; then
|
|
|
|
echo "Skipping for $GIT_RELEASE_BOT_NAME commit"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Filter the branch to execute the release on
|
2020-05-05 12:48:16 -05:00
|
|
|
readonly local current_branch=$(git rev-parse --abbrev-ref HEAD)
|
2020-03-10 16:48:39 -05:00
|
|
|
echo "Current branch: ${branch}"
|
2020-05-05 12:48:16 -05:00
|
|
|
if [[ -n "$RELEASE_BRANCH_NAME" && ! "${current_branch}" = "$RELEASE_BRANCH_NAME" ]]; then
|
|
|
|
echo "Skipping for ${current_branch} branch"
|
2020-03-10 16:48:39 -05:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Making sure we are on top of the branch
|
|
|
|
echo "Git checkout branch ${GITHUB_REF##*/}"
|
|
|
|
git checkout ${GITHUB_REF##*/}
|
|
|
|
echo "Git reset hard to ${GITHUB_SHA}"
|
|
|
|
git reset --hard ${GITHUB_SHA}
|
|
|
|
|
|
|
|
echo "Do mvn release:perform..."
|
|
|
|
#mvn $MAVEN_REPO_LOCAL --batch-mode --global-settings release.xml release:perform
|
2020-03-12 03:45:50 -05:00
|
|
|
mvn --batch-mode --global-settings release.xml release:perform -DskipTests
|
2020-03-10 16:48:39 -05:00
|
|
|
|