From 6f6998a3438831a5405d724c6a9ea5ab3e7dbd45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wenkai=20Yin=28=E5=B0=B9=E6=96=87=E5=BC=80=29?= Date: Mon, 21 Feb 2022 17:45:58 +0800 Subject: [PATCH 1/2] Enable building and pushing image for release branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable building and pushing image for release branches Signed-off-by: Wenkai Yin(尹文开) --- .github/workflows/push.yml | 4 +++- hack/docker-push.sh | 23 +++++++++-------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4d232ef9d..9bcf750f4 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -2,7 +2,9 @@ name: Main CI on: push: - branches: [ main ] + branches: + - 'main' + - 'release-**' tags: - '*' diff --git a/hack/docker-push.sh b/hack/docker-push.sh index cf3a0c5f8..8ad3df113 100755 --- a/hack/docker-push.sh +++ b/hack/docker-push.sh @@ -56,26 +56,21 @@ elif [[ "$triggeredBy" == "tags" ]]; then TAG=$(echo $GITHUB_REF | cut -d / -f 3) fi -if [[ "$BRANCH" == "main" ]]; then - VERSION="$BRANCH" -elif [[ ! -z "$TAG" ]]; then +TAG_LATEST=false +if [[ ! -z "$TAG" ]]; then + echo "We're building tag $TAG" + VERSION="$TAG" # Explicitly checkout tags when building from a git tag. # This is not needed when building from main git fetch --tags # Calculate the latest release if there's a tag. highest_release - VERSION="$TAG" + if [[ "$TAG" == "$HIGHEST" ]]; then + TAG_LATEST=true + fi else - echo "We're not on main and we're not building a tag, exit early." - exit 0 -fi - -# Assume we're not tagging `latest` by default, and never on main. -TAG_LATEST=false -if [[ "$BRANCH" == "main" ]]; then - echo "Building main, not tagging latest." -elif [[ "$TAG" == "$HIGHEST" ]]; then - TAG_LATEST=true + echo "We're on branch $BRANCH" + VERSION="$BRANCH" fi if [[ -z "$BUILDX_PLATFORMS" ]]; then From 81d91dbb97a8bd165479245c42a3c987fd93b77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wenkai=20Yin=28=E5=B0=B9=E6=96=87=E5=BC=80=29?= Date: Mon, 21 Feb 2022 19:10:30 +0800 Subject: [PATCH 2/2] Append "-dev" suffix for the image tag of release branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Append "-dev" suffix for the image tag of release branches: release-1.0-dev Signed-off-by: Wenkai Yin(尹文开) --- hack/docker-push.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hack/docker-push.sh b/hack/docker-push.sh index 8ad3df113..d9f1835b8 100755 --- a/hack/docker-push.sh +++ b/hack/docker-push.sh @@ -71,6 +71,9 @@ if [[ ! -z "$TAG" ]]; then else echo "We're on branch $BRANCH" VERSION="$BRANCH" + if [[ "$VERSION" == release-* ]]; then + VERSION=${VERSION}-dev + fi fi if [[ -z "$BUILDX_PLATFORMS" ]]; then @@ -82,6 +85,7 @@ echo "Highest tag found: $HIGHEST" echo "BRANCH: $BRANCH" echo "TAG: $TAG" echo "TAG_LATEST: $TAG_LATEST" +echo "VERSION: $VERSION" echo "BUILDX_PLATFORMS: $BUILDX_PLATFORMS" echo "Building and pushing container images."