diff --git a/deploy/ci/tasks/dev-releases/check-gh-release.yml b/deploy/ci/tasks/dev-releases/check-gh-release.yml index b9a23fc69f..64c34f6ddd 100644 --- a/deploy/ci/tasks/dev-releases/check-gh-release.yml +++ b/deploy/ci/tasks/dev-releases/check-gh-release.yml @@ -16,14 +16,13 @@ run: - | # Check that the Github release DOES NOT exist ROOT_DIR=${PWD} - VERSION=$(cat image-tag/v2-version) - FULL_VERSION=$(cat image-tag/v2-alpha-tag) - GIT_TAG=$(cat image-tag/v2-tag) STRATOS=${ROOT_DIR}/stratos + source "${STRATOS}/deploy/ci/tasks/dev-releases/vars-helper.sh" + source ${STRATOS}/deploy/ci/tasks/dev-releases/github-helper.sh # Check tagged release version is consistent with package.json version - TAG_RELEASE_VERSION=$(echo ${FULL_VERSION} | cut -d"-" -f1) + TAG_RELEASE_VERSION=$(echo ${LATEST_TAG} | cut -d"-" -f1) if [ "${TAG_RELEASE_VERSION}" != "${VERSION}" ]; then echo "Package.json version is not consistent with tag release version! ${TAG_RELEASE_VERSION} != ${VERSION}" exit 1 @@ -32,7 +31,7 @@ run: # Check that the release exists set +e - github-release info -t ${GIT_TAG} + github-release info -t ${RELEASE_TAG} RETVAL=$? set -e diff --git a/deploy/ci/tasks/dev-releases/create-chart.yml b/deploy/ci/tasks/dev-releases/create-chart.yml index 9cb8935fd7..55fb8f9eca 100644 --- a/deploy/ci/tasks/dev-releases/create-chart.yml +++ b/deploy/ci/tasks/dev-releases/create-chart.yml @@ -21,12 +21,14 @@ run: helm init --client-only ROOT_DIR=$PWD STRATOS=${ROOT_DIR}/stratos + source "${STRATOS}/deploy/ci/tasks/dev-releases/vars-helper.sh" + source ${STRATOS}/deploy/ci/tasks/dev-releases/create-chart-helper.sh HELM_REPO=${ROOT_DIR}/helm-repo/${HELM_REPO_PATH} - GIT_TAG=$(cat image-tag/v2-alpha-tag) - VERSION=$(cat image-tag/v2-version) - RELEASE_VERSION=$(cat image-tag/v2-tag) - COMMIT=$(cat image-tag/v2-commit) + + GIT_TAG=${LATEST_TAG} + RELEASE_VERSION=${RELEASE_TAG} + COMMIT=${COMMIT_HASH} # Required for setupAndPushChange commit message IMAGE_TAG=${GIT_TAG} diff --git a/deploy/ci/tasks/dev-releases/generate-tag-files.yml b/deploy/ci/tasks/dev-releases/generate-tag-files.yml index 7514062f0a..1a56bae074 100644 --- a/deploy/ci/tasks/dev-releases/generate-tag-files.yml +++ b/deploy/ci/tasks/dev-releases/generate-tag-files.yml @@ -18,39 +18,12 @@ run: - | echo "Generate tag files started..." + ROOT_DIR=${PWD} + STRATOS=${ROOT_DIR}/stratos + source "${STRATOS}/deploy/ci/tasks/dev-releases/vars-helper.sh" + cd stratos - # RELEASE_TAG is the full tag that started the pipleine, e.g. '2.0.0-rc.1' - RELEASE_TAG=$(cat .git/ref) - - VERSION=$(cat package.json | grep version | grep -Po "([0-9\.]?)*") - COMMIT_HASH=$(git log -1 --format="%h") - LATEST_TAG=$VERSION-${COMMIT_HASH} - SOURCE_CODE_REPO=$(git config --get remote.origin.url) - - # Check that the RELEASE_TAG matches the version - if [[ "${RELEASE_TAG}" != ${VERSION}* ]]; then - echo ".git/ref is not the expected release tag - falling back to git describe" - RELEASE_TAG=$(git describe) - if [[ "${RELEASE_TAG}" != ${VERSION}* ]]; then - echo "Error: Can not get tag for this release - got ${RELEASE_TAG}" - exit 1 - fi - fi - - echo "Got Release tag ${RELEASE_TAG}" - - echo "Got version $VERSION from package.json." - - echo "Got $LATEST_TAG as the latest git tag." - - if [ ! -z ${TAG_SUFFIX} ]; then - if [ "${TAG_SUFFIX}" != "null" ]; then - echo "Adding tag suffix '$TAG_SUFFIX' to the latest tag." - LATEST_TAG=${LATEST_TAG}-${TAG_SUFFIX} - echo "The latest tag is now $LATEST_TAG." - fi - fi echo "Running store-git-metadata.sh..." ./build/store-git-metadata.sh diff --git a/deploy/ci/tasks/dev-releases/update-gh-release.yml b/deploy/ci/tasks/dev-releases/update-gh-release.yml index 80a79a98ec..f3897c03d3 100644 --- a/deploy/ci/tasks/dev-releases/update-gh-release.yml +++ b/deploy/ci/tasks/dev-releases/update-gh-release.yml @@ -17,10 +17,12 @@ run: - | # Create Github release ROOT_DIR=${PWD} - VERSION=$(cat image-tag/v2-version) - FULL_VERSION=$(cat image-tag/v2-alpha-tag) - GIT_TAG=$(cat image-tag/v2-tag) STRATOS=${ROOT_DIR}/stratos + source "${STRATOS}/deploy/ci/tasks/dev-releases/vars-helper.sh" + + FULL_VERSION=${LATEST_TAG} + GIT_TAG=${RELEASE_TAG} + source ${STRATOS}/deploy/ci/tasks/dev-releases/github-helper.sh # Check tagged release version is consistent with package.json version diff --git a/deploy/ci/tasks/dev-releases/vars-helper.sh b/deploy/ci/tasks/dev-releases/vars-helper.sh new file mode 100755 index 0000000000..edc0c1cd16 --- /dev/null +++ b/deploy/ci/tasks/dev-releases/vars-helper.sh @@ -0,0 +1,32 @@ + +pushd stratos + +VERSION=$(cat package.json | grep version | grep -Po "([0-9\.]?)*") +COMMIT_HASH=$(git log -1 --format="%h") +LATEST_TAG=$VERSION-${COMMIT_HASH} +SOURCE_CODE_REPO=$(git config --get remote.origin.url) + +# Check that the RELEASE_TAG matches the version +RELEASE_TAG=$(git describe) +if [[ "${RELEASE_TAG}" != ${VERSION}* ]]; then + echo "Error: Can not get tag for this release - got ${RELEASE_TAG}" + exit 1 +fi + +if [ ! -z ${TAG_SUFFIX} ]; then + if [ "${TAG_SUFFIX}" != "null" ]; then + echo "Adding tag suffix '$TAG_SUFFIX' to the latest tag." + LATEST_TAG=${LATEST_TAG}-${TAG_SUFFIX} + echo "The latest tag is now $LATEST_TAG." + fi +fi + +popd + +set +x +echo "VERSION : ${VERSION}" +echo "COMMIT_HASH : ${COMMIT_HASH}" +echo "LATEST_TAG : ${LATEST_TAG}" +echo "SOURCE_CODE_REPO : ${SOURCE_CODE_REPO}" +echo "RELEASE_TAG : ${RELEASE_TAG}" +set -x