From 9195db0e36e3573a78c1b04c713f2fca13b1f028 Mon Sep 17 00:00:00 2001 From: Mustapha Zorgati <15628173+mustaphazorgati@users.noreply.github.com> Date: Thu, 5 Apr 2018 09:43:34 +0200 Subject: [PATCH] now changing release version before building and testing --- .travis.yml | 1 + lib/deployment/change_version.sh | 47 ++++++++++++++++++++++++++++++++ lib/deployment/release.sh | 8 ------ 3 files changed, 48 insertions(+), 8 deletions(-) create mode 100755 lib/deployment/change_version.sh diff --git a/.travis.yml b/.travis.yml index 62f01714a..ffd79a842 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ cache: before_install: - nvm install $NODE_VERSION - npm install -g @angular/cli >/dev/null 2>&1 + - lib/deployment/change_version.sh rest/ lib/ install: - (cd workplace && npm install --no-progress && ng build --environment=prod --no-progress) && (cd web && npm install --no-progress && npm run build:prod) diff --git a/lib/deployment/change_version.sh b/lib/deployment/change_version.sh new file mode 100755 index 000000000..d101b0b34 --- /dev/null +++ b/lib/deployment/change_version.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -e #fail fast + +#H Usage: +#H change_version.sh -h | change_version.sh --help +#H +#H prints this help and exits +#H +#H change_version.sh [modules...] +#H +#H if a release version exists (extracted from TRAVIS_TAG) +#H the maven versions of all modules will be changed to the given release version. +#H +#H Environment variables: +#H - TRAVIS_TAG +#H if this is a tagged build then TRAVIS_TAG contains the version number. +#H pattern: v[DIGIT].[DIGIT].[DIGIT] +# Arguments: +# $1: exitcode +function helpAndExit { + cat "$0" | grep "^#H" | cut -c4- + exit "$1" +} + +# changing version in pom and all its children +# Arguments: +# $1: directory of pom +# $2: new version +function change_version { + $debug mvn org.codehaus.mojo:versions-maven-plugin:2.5:set -f "$1" -DnewVersion="$2" -DartifactId=* -DgroupId=* +} + +function main { + if [[ $# -eq 0 || "$1" == "-h" || "$1" == "--help" ]]; then + helpAndExit 0 + fi + if [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + while [[ $# -gt 0 ]]; do + change_version "$1" "${TRAVIS_TAG##v}" + shift + done + else + echo "skipped version change because this is not a release build" + fi +} + +main "$@" diff --git a/lib/deployment/release.sh b/lib/deployment/release.sh index 5e2a6b241..516467dce 100755 --- a/lib/deployment/release.sh +++ b/lib/deployment/release.sh @@ -273,14 +273,6 @@ function main { branch="BRANCH" echo "!!! - Skipping automatic detection of tag branch. Instead using '$branch'" fi - - if [[ -n "$PARENT_DIR" ]]; then - change_version "$PARENT_DIR" "${TRAVIS_TAG##v}" - else - for dir in ${MODULES[@]}; do - change_version "$dir" "${TRAVIS_TAG##v}" - done - fi else if [[ "$TRAVIS_BRANCH" != 'master' ]]; then echo "Skipping release to sonatype because this branch is not permitted"