|
22 | 22 | exit 1 |
23 | 23 | fi |
24 | 24 |
|
| 25 | +function pushBuildx() { |
| 26 | + BUILD_TAG="latest" |
| 27 | + TARGET_IMG=${DIMAGE} |
| 28 | + |
| 29 | +# TODO Currently ci builds with commit tag will not be generated, |
| 30 | +# since buildx does not support multiple repo |
| 31 | + # if not a release build set the tag and ci image |
| 32 | + if [ -z "${RELEASE_TAG}" ]; then |
| 33 | + return |
| 34 | +# BUILD_ID=$(git describe --tags --always) |
| 35 | +# BUILD_TAG="${BRANCH}-${BUILD_ID}" |
| 36 | +# TARGET_IMG="${DIMAGE}-ci" |
| 37 | + fi |
| 38 | + |
| 39 | + echo "Tagging and pushing ${DIMAGE}:${TAG} as ${TARGET_IMG}:${BUILD_TAG}" |
| 40 | + docker buildx imagetools create "${DIMAGE}:${TAG}" -t "${TARGET_IMG}:${BUILD_TAG}" |
| 41 | +} |
| 42 | + |
| 43 | +# if the push is for a buildx build |
| 44 | +if [[ ${BUILDX} ]]; then |
| 45 | + pushBuildx |
| 46 | + exit 0 |
| 47 | +fi |
| 48 | + |
25 | 49 | IMAGEID=$( sudo docker images -q ${DIMAGE}:ci ) |
26 | 50 | echo "${DIMAGE}:ci -> $IMAGEID" |
27 | 51 | if [ -z ${IMAGEID} ]; |
@@ -55,7 +79,11 @@ echo "Set the build/unique image tag as: ${BUILD_TAG}" |
55 | 79 |
|
56 | 80 | function TagAndPushImage() { |
57 | 81 | REPO="$1" |
58 | | - TAG="$2" |
| 82 | + # Trim the `v` from the TAG if it exists |
| 83 | + # Example: v1.10.0 maps to 1.10.0 |
| 84 | + # Example: 1.10.0 maps to 1.10.0 |
| 85 | + # Example: v1.10.0-custom maps to 1.10.0-custom |
| 86 | + TAG="${2#v}" |
59 | 87 |
|
60 | 88 | #Add an option to specify a custom TAG_SUFFIX |
61 | 89 | #via environment variable. Default is no tag. |
|
83 | 111 | # Push with different tags if tagged as a release |
84 | 112 | # When github is tagged with a release, then Travis will |
85 | 113 | # set the release tag in env 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}" |
| 114 | + TagAndPushImage "${DIMAGE}" "${TRAVIS_TAG}" |
91 | 115 | TagAndPushImage "${DIMAGE}" "latest" |
92 | 116 | fi; |
93 | 117 | else |
|
108 | 132 | # When github is tagged with a release, then Travis will |
109 | 133 | # set the release tag in env TRAVIS_TAG |
110 | 134 | # Trim the `v` from the TRAVIS_TAG if it exists |
111 | | - TagAndPushImage "quay.io/${DIMAGE}" "${TRAVIS_TAG#v}" |
| 135 | + TagAndPushImage "quay.io/${DIMAGE}" "${TRAVIS_TAG}" |
112 | 136 | TagAndPushImage "quay.io/${DIMAGE}" "latest" |
113 | 137 | fi; |
114 | 138 | else |
|
0 commit comments