From 27c77199128ef6727f17c4d53b85c22b83644cb6 Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Tue, 9 May 2023 13:02:54 -0500 Subject: [PATCH] Updates to work with branch-specific maven deployments in/with circleci [skip ci] --- .circleci/adjust-pom-version.sh | 23 +++++++++++++++++++++++ .circleci/config.yml | 4 ++++ 2 files changed, 27 insertions(+) create mode 100755 .circleci/adjust-pom-version.sh diff --git a/.circleci/adjust-pom-version.sh b/.circleci/adjust-pom-version.sh new file mode 100755 index 0000000..054fbdf --- /dev/null +++ b/.circleci/adjust-pom-version.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ -z "$CIRCLE_BRANCH" ] && [ -z "$CIRCLE_TAG" ]; then + echo "Error: env vars CIRCLE_BRANCH and CIRCLE_TAG were not set." + exit 1; +fi + +if [ "$CIRCLE_BRANCH" == "dev" ] || [ "$CIRCLE_BRANCH" == "staging" ] || [ "$CIRCLE_BRANCH" == "main" ]; then + echo "On a primary branch [$CIRCLE_BRANCH] - will not edit the pom version."; + exit 0; +fi + +if [ -n "$CIRCLE_BRANCH" ]; then + SLUG=$(echo $CIRCLE_BRANCH | sed 's/[^a-zA-Z0-9]/-/g') +else + SLUG=$(echo $CIRCLE_TAG | sed 's/^snapshot-//g') +fi + +POM=$(dirname $0)/../pom.xml + +echo "Updating $POM to: $SLUG-SNAPSHOT" +sed -i "s/.*/$SLUG-SNAPSHOT<\/revision>/" $POM +git diff $POM diff --git a/.circleci/config.yml b/.circleci/config.yml index f6d9483..99c4892 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -71,6 +71,10 @@ commands: mvn_deploy: steps: - checkout + - run: + name: Adjust pom version + command: | + .circleci/adjust-pom-version.sh - restore_cache: keys: - v1-dependencies-{{ checksum "pom.xml" }}