Skip to content

Commit

Permalink
ci(release): create a dedicated Maven publish script for releasing (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
Djaytan authored Feb 23, 2024
1 parent 445bfc5 commit 6252c80
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .github/release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}'`
}
],
Expand Down
29 changes: 29 additions & 0 deletions .github/scripts/publish_maven_artifacts.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6252c80

Please sign in to comment.