From 31e4bc244933054a7e2fc6ad6d7cea1cb7441c22 Mon Sep 17 00:00:00 2001 From: Kiran Mova Date: Wed, 6 May 2020 23:28:15 +0530 Subject: [PATCH] refactor(travis): tag to release branch conversion (#56) There are cases where the tags can be on custom release branches like v1.9.x-hotfix or v1.9.x-custom, apart from regular release branch (v1.9.x). This commit helps with translating the given tag to corresponding release branch with custom suffixes. Using the new logic, some examples of tag to branch mappings are: v1.9.0-RC1 => v1.9.x v1.9.0-hotfixid => v1.9.x-hotfixid v1.9.0 => v1.9.x v1.9.1 => v1.9.x v1.9.0-custom-RC1 => v1.9.x-custom v1.9.0-custom => v1.9.x-custom v1.9.1-custom => v1.9.x-custom Signed-off-by: kmova --- .travis.yml | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c0660c4..395e0f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -80,10 +80,22 @@ script: # If this build is running due to travis release tag, then # go ahead and tag the dependent repo. # - # $TRAVIS_BRANCH contains the same value as $TRAVIS_TAG. - # Example: v1.9.0-RC1 tag and 1.9.0-RC1 branch. - # OpenEBS release are done from branches named as v1.9.x. # Convert the TRAVIS_TAG to the corresponding release branch. + # $TRAVIS_BRANCH contains the same value as $TRAVIS_TAG. + # Example: TRAVIS_TAG and TRAVIS_BRANCH will have v1.9.0-RC1, + # when github release tag is v1.9.0-RC1 + # + # OpenEBS release are triggered from release branches that are named + # as v1.9.x or v1.9.x-hotfix or v1.9.x-custom + # + # The tag to release branch conversion should be handled as follows: + # v1.9.0-RC1 => should be v1.9.x + # v1.9.0-hotfixid => should be v1.9.x-hotfixid + # v1.9.0 => should be v1.9.x + # v1.9.1 => should be v1.9.x + # v1.9.0-custom-RC1 => should be v1.9.x-custom + # v1.9.0-custom => should be v1.9.x-custom + # v1.9.1-custom => should be v1.9.x-custom # # Allow for building forked openebs pipelines. # Tag the downstream repos under current repo org. @@ -92,7 +104,13 @@ script: export REPO_ORG; fi - if [ ! -z $TRAVIS_TAG ] && [ "$TRAVIS_REPO_SLUG" == "$REPO_ORG/libcstor" ]; then - REL_BRANCH=$(echo $(echo "$TRAVIS_TAG" | cut -d'-' -f1 | rev | cut -d'.' -f2- | rev).x) ; + TAG_SUFFIX=$(echo "$TRAVIS_TAG" | cut -d'-' -f2); + if [ "$TAG_SUFFIX" == "$TRAVIS_TAG" ] || [[ $TAG_SUFFIX =~ ^RC ]]; then + REL_SUFFIX=""; + else + REL_SUFFIX="-$TAG_SUFFIX"; + fi; + REL_BRANCH=$(echo $(echo "$TRAVIS_TAG" | cut -d'-' -f1 | rev | cut -d'.' -f2- | rev).x$REL_SUFFIX) ; ./buildscripts/git-release "$REPO_ORG/cstor" "$TRAVIS_TAG" "$REL_BRANCH" || travis_terminate 1; fi after_failure: