diff --git a/.github/release.config.js b/.github/release.config.js index e5faac6..fbcd2fd 100644 --- a/.github/release.config.js +++ b/.github/release.config.js @@ -37,8 +37,7 @@ module.exports = { [ '@semantic-release/exec', { - prepareCmd: 'mvn versions:set -DnewVersion="${nextRelease.gitTag}" --batch-mode --errors', - publishCmd: 'mvn deploy --activate-profiles release -Dstyle.color=always --batch-mode --errors --strict-checksums --update-snapshots', + publishCmd: './scripts/publish_maven_artifacts.sh ${nextRelease.version}', successCmd: `echo '$\{nextRelease.gitTag}' > '${process.env.TMP_TAG_VERSION_NAME_FILE}'` } ], diff --git a/.github/scripts/publish_maven_artifacts.sh b/.github/scripts/publish_maven_artifacts.sh new file mode 100755 index 0000000..01a8def --- /dev/null +++ b/.github/scripts/publish_maven_artifacts.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# +# Publish Maven artifacts + +set -Eeuo pipefail +trap 'echo "Error encountered while executing the script." >&2' ERR + +SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P); readonly SCRIPT_DIR +ROOT_REPOSITORY_DIR="$(realpath "${SCRIPT_DIR}/../..")"; readonly ROOT_REPOSITORY_DIR + +readonly NEW_VERSION="$1" +readonly DEV_VERSION='0.0.1-DEV-SNAPSHOT' + +main() { + echo "Publishing version ${NEW_VERSION}..." + + cd "${ROOT_REPOSITORY_DIR}" + + mvn versions:set -DnewVersion="${NEW_VERSION}" --batch-mode --errors + mvn deploy --activate-profiles release -Dstyle.color=always \ + --batch-mode --errors --strict-checksums --update-snapshots + + echo "The new version ${NEW_VERSION} has been published successfully!" + + echo 'Putting back the DEV version...' + mvn versions:set -DnewVersion="${DEV_VERSION}" --batch-mode --errors +} + +main