Skip to content

Commit

Permalink
Release Pipelines: Always read vars from git checkout (#4597)
Browse files Browse the repository at this point in the history
* Always read vars from git checkout

* FIx create chart
  • Loading branch information
nwmac authored Sep 21, 2020
1 parent fffe26f commit 246673b
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 43 deletions.
9 changes: 4 additions & 5 deletions deploy/ci/tasks/dev-releases/check-gh-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions deploy/ci/tasks/dev-releases/create-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
35 changes: 4 additions & 31 deletions deploy/ci/tasks/dev-releases/generate-tag-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions deploy/ci/tasks/dev-releases/update-gh-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions deploy/ci/tasks/dev-releases/vars-helper.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 246673b

Please sign in to comment.