Skip to content

Commit 246673b

Browse files
authored
Release Pipelines: Always read vars from git checkout (#4597)
* Always read vars from git checkout * FIx create chart
1 parent fffe26f commit 246673b

File tree

5 files changed

+51
-43
lines changed

5 files changed

+51
-43
lines changed

deploy/ci/tasks/dev-releases/check-gh-release.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ run:
1616
- |
1717
# Check that the Github release DOES NOT exist
1818
ROOT_DIR=${PWD}
19-
VERSION=$(cat image-tag/v2-version)
20-
FULL_VERSION=$(cat image-tag/v2-alpha-tag)
21-
GIT_TAG=$(cat image-tag/v2-tag)
2219
STRATOS=${ROOT_DIR}/stratos
20+
source "${STRATOS}/deploy/ci/tasks/dev-releases/vars-helper.sh"
21+
2322
source ${STRATOS}/deploy/ci/tasks/dev-releases/github-helper.sh
2423
2524
# Check tagged release version is consistent with package.json version
26-
TAG_RELEASE_VERSION=$(echo ${FULL_VERSION} | cut -d"-" -f1)
25+
TAG_RELEASE_VERSION=$(echo ${LATEST_TAG} | cut -d"-" -f1)
2726
if [ "${TAG_RELEASE_VERSION}" != "${VERSION}" ]; then
2827
echo "Package.json version is not consistent with tag release version! ${TAG_RELEASE_VERSION} != ${VERSION}"
2928
exit 1
@@ -32,7 +31,7 @@ run:
3231
3332
# Check that the release exists
3433
set +e
35-
github-release info -t ${GIT_TAG}
34+
github-release info -t ${RELEASE_TAG}
3635
RETVAL=$?
3736
set -e
3837

deploy/ci/tasks/dev-releases/create-chart.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ run:
2121
helm init --client-only
2222
ROOT_DIR=$PWD
2323
STRATOS=${ROOT_DIR}/stratos
24+
source "${STRATOS}/deploy/ci/tasks/dev-releases/vars-helper.sh"
25+
2426
source ${STRATOS}/deploy/ci/tasks/dev-releases/create-chart-helper.sh
2527
HELM_REPO=${ROOT_DIR}/helm-repo/${HELM_REPO_PATH}
26-
GIT_TAG=$(cat image-tag/v2-alpha-tag)
27-
VERSION=$(cat image-tag/v2-version)
28-
RELEASE_VERSION=$(cat image-tag/v2-tag)
29-
COMMIT=$(cat image-tag/v2-commit)
28+
29+
GIT_TAG=${LATEST_TAG}
30+
RELEASE_VERSION=${RELEASE_TAG}
31+
COMMIT=${COMMIT_HASH}
3032
3133
# Required for setupAndPushChange commit message
3234
IMAGE_TAG=${GIT_TAG}

deploy/ci/tasks/dev-releases/generate-tag-files.yml

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,12 @@ run:
1818
- |
1919
echo "Generate tag files started..."
2020
21+
ROOT_DIR=${PWD}
22+
STRATOS=${ROOT_DIR}/stratos
23+
source "${STRATOS}/deploy/ci/tasks/dev-releases/vars-helper.sh"
24+
2125
cd stratos
2226
23-
# RELEASE_TAG is the full tag that started the pipleine, e.g. '2.0.0-rc.1'
24-
RELEASE_TAG=$(cat .git/ref)
25-
26-
VERSION=$(cat package.json | grep version | grep -Po "([0-9\.]?)*")
27-
COMMIT_HASH=$(git log -1 --format="%h")
28-
LATEST_TAG=$VERSION-${COMMIT_HASH}
29-
SOURCE_CODE_REPO=$(git config --get remote.origin.url)
30-
31-
# Check that the RELEASE_TAG matches the version
32-
if [[ "${RELEASE_TAG}" != ${VERSION}* ]]; then
33-
echo ".git/ref is not the expected release tag - falling back to git describe"
34-
RELEASE_TAG=$(git describe)
35-
if [[ "${RELEASE_TAG}" != ${VERSION}* ]]; then
36-
echo "Error: Can not get tag for this release - got ${RELEASE_TAG}"
37-
exit 1
38-
fi
39-
fi
40-
41-
echo "Got Release tag ${RELEASE_TAG}"
42-
43-
echo "Got version $VERSION from package.json."
44-
45-
echo "Got $LATEST_TAG as the latest git tag."
46-
47-
if [ ! -z ${TAG_SUFFIX} ]; then
48-
if [ "${TAG_SUFFIX}" != "null" ]; then
49-
echo "Adding tag suffix '$TAG_SUFFIX' to the latest tag."
50-
LATEST_TAG=${LATEST_TAG}-${TAG_SUFFIX}
51-
echo "The latest tag is now $LATEST_TAG."
52-
fi
53-
fi
5427
echo "Running store-git-metadata.sh..."
5528
5629
./build/store-git-metadata.sh

deploy/ci/tasks/dev-releases/update-gh-release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ run:
1717
- |
1818
# Create Github release
1919
ROOT_DIR=${PWD}
20-
VERSION=$(cat image-tag/v2-version)
21-
FULL_VERSION=$(cat image-tag/v2-alpha-tag)
22-
GIT_TAG=$(cat image-tag/v2-tag)
2320
STRATOS=${ROOT_DIR}/stratos
21+
source "${STRATOS}/deploy/ci/tasks/dev-releases/vars-helper.sh"
22+
23+
FULL_VERSION=${LATEST_TAG}
24+
GIT_TAG=${RELEASE_TAG}
25+
2426
source ${STRATOS}/deploy/ci/tasks/dev-releases/github-helper.sh
2527
2628
# Check tagged release version is consistent with package.json version
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
pushd stratos
3+
4+
VERSION=$(cat package.json | grep version | grep -Po "([0-9\.]?)*")
5+
COMMIT_HASH=$(git log -1 --format="%h")
6+
LATEST_TAG=$VERSION-${COMMIT_HASH}
7+
SOURCE_CODE_REPO=$(git config --get remote.origin.url)
8+
9+
# Check that the RELEASE_TAG matches the version
10+
RELEASE_TAG=$(git describe)
11+
if [[ "${RELEASE_TAG}" != ${VERSION}* ]]; then
12+
echo "Error: Can not get tag for this release - got ${RELEASE_TAG}"
13+
exit 1
14+
fi
15+
16+
if [ ! -z ${TAG_SUFFIX} ]; then
17+
if [ "${TAG_SUFFIX}" != "null" ]; then
18+
echo "Adding tag suffix '$TAG_SUFFIX' to the latest tag."
19+
LATEST_TAG=${LATEST_TAG}-${TAG_SUFFIX}
20+
echo "The latest tag is now $LATEST_TAG."
21+
fi
22+
fi
23+
24+
popd
25+
26+
set +x
27+
echo "VERSION : ${VERSION}"
28+
echo "COMMIT_HASH : ${COMMIT_HASH}"
29+
echo "LATEST_TAG : ${LATEST_TAG}"
30+
echo "SOURCE_CODE_REPO : ${SOURCE_CODE_REPO}"
31+
echo "RELEASE_TAG : ${RELEASE_TAG}"
32+
set -x

0 commit comments

Comments
 (0)