From 7d052d088cbe399c2092cf80b4ae341f12550186 Mon Sep 17 00:00:00 2001 From: Jonathan Knight Date: Wed, 26 Apr 2023 12:08:03 +0300 Subject: [PATCH] Fix the "Deploy Snapshots" action to only run for snapshot versions --- .github/workflows/deploy-snapshots.yaml | 2 +- etc/deploy-snapshots.sh | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 etc/deploy-snapshots.sh diff --git a/.github/workflows/deploy-snapshots.yaml b/.github/workflows/deploy-snapshots.yaml index 950bb582..5cef2a3a 100644 --- a/.github/workflows/deploy-snapshots.yaml +++ b/.github/workflows/deploy-snapshots.yaml @@ -55,4 +55,4 @@ jobs: git checkout "${GIT_COMMIT}" git config --local user.name "${GIT_USER}" git config --local user.email "${GIT_EMAIL}" - mvn -s ./.mvn/settings.xml -B clean deploy -DskipTests -Pcoherence-ce -Dgithub.build=true + sh etc/deploy-snapshots.sh diff --git a/etc/deploy-snapshots.sh b/etc/deploy-snapshots.sh new file mode 100755 index 00000000..64b9ad7e --- /dev/null +++ b/etc/deploy-snapshots.sh @@ -0,0 +1,17 @@ +#!/bin/sh +set -e + +CURRENT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.4.0:evaluate -Dexpression=project.version -nsu | grep -e '^[[:digit:]]') + +if [ "${CURRENT_VERSION}" = "" ]; then + echo "Could not find current version from Maven" + exit 1 +fi + +if [ -z $(echo "${CURRENT_VERSION}" | grep SNAPSHOT) ]; then + echo "This job only deploys SNAPSHOT versions, skipping version ${CURRENT_VERSION}" + exit 0 +fi + +echo "Building version ${CURRENT_VERSION}" +mvn -s ./.mvn/settings.xml -B clean deploy -DskipTests -Pcoherence-ce -Dgithub.build=true