Skip to content

Commit 2d1e613

Browse files
author
kmova
committed
refactor(build): trim leading v from travis tag
Updating the push script with the new release conventions. The GitHub release tags will have a leading v. Example v1.10.0 The docker images will be tagged by trimming the leading v. Example 1.10.0 Also, the travis can setup some custom suffix for the tags, like dev or debug. Signed-off-by: kmova <[email protected]>
1 parent fc33a50 commit 2d1e613

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

buildscripts/push

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
#!/bin/bash
2+
3+
# Copyright 2020 The OpenEBS Authors. All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
217
set -e
318

419
if [ -z ${DIMAGE} ];
@@ -42,7 +57,10 @@ function TagAndPushImage() {
4257
REPO="$1"
4358
TAG="$2"
4459

45-
IMAGE_URI="${REPO}:${TAG}";
60+
#Add an option to specify a custom TAG_SUFFIX
61+
#via environment variable. Default is no tag.
62+
#Example suffix could be "-debug" of "-dev"
63+
IMAGE_URI="${REPO}:${TAG}${TAG_SUFFIX}";
4664
sudo docker tag ${IMAGEID} ${IMAGE_URI};
4765
echo " push ${IMAGE_URI}";
4866
sudo docker push ${IMAGE_URI};
@@ -65,7 +83,11 @@ then
6583
# Push with different tags if tagged as a release
6684
# When github is tagged with a release, then Travis will
6785
# set the release tag in env TRAVIS_TAG
68-
TagAndPushImage "${DIMAGE}" "${TRAVIS_TAG}"
86+
# Trim the `v` from the TRAVIS_TAG if it exists
87+
# Example: v1.10.0 maps to 1.10.0
88+
# Example: 1.10.0 maps to 1.10.0
89+
# Example: v1.10.0-custom maps to 1.10.0-custom
90+
TagAndPushImage "${DIMAGE}" "${TRAVIS_TAG#v}"
6991
TagAndPushImage "${DIMAGE}" "latest"
7092
fi;
7193
else
@@ -85,7 +107,8 @@ then
85107
# Push with different tags if tagged as a release
86108
# When github is tagged with a release, then Travis will
87109
# set the release tag in env TRAVIS_TAG
88-
TagAndPushImage "quay.io/${DIMAGE}" "${TRAVIS_TAG}"
110+
# Trim the `v` from the TRAVIS_TAG if it exists
111+
TagAndPushImage "quay.io/${DIMAGE}" "${TRAVIS_TAG#v}"
89112
TagAndPushImage "quay.io/${DIMAGE}" "latest"
90113
fi;
91114
else

0 commit comments

Comments
 (0)