From e0548a07a78ac1b889637bce3734c611507f33ab Mon Sep 17 00:00:00 2001 From: Zoupers Date: Sat, 22 Mar 2025 10:48:00 +0800 Subject: [PATCH 1/7] feat: add release channel tag to image Signed-off-by: Zoupers --- .github/workflows/release.yaml | 5 +++++ scripts/image_tag.sh | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fbb86d7aaf799..7f6cc473d2138 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -497,6 +497,11 @@ jobs: else echo "created_latest_tag=false" >> $GITHUB_OUTPUT fi + # push image based on current channel + ./scripts/build_docker_multiarch.sh \ + --push \ + --target "$(./scripts/image_tag.sh --channel ${CODER_RELEASE_CHANNEL})" \ + $(cat build/coder_"$version"_linux_{amd64,arm64,armv7}.tag) env: CODER_BASE_IMAGE_TAG: ${{ steps.image-base-tag.outputs.tag }} diff --git a/scripts/image_tag.sh b/scripts/image_tag.sh index 68dfbcebf99cb..25c7d538d34b8 100755 --- a/scripts/image_tag.sh +++ b/scripts/image_tag.sh @@ -11,6 +11,9 @@ # If no version is specified, defaults to the version from ./version.sh. If the # supplied version is "latest", no `v` prefix will be added to the tag. # +# The --channel parameter indecates the specific release channel, it's conflicts +# with --version parameter. +# # The returned tag will be sanitized to remove invalid characters like the plus # sign. @@ -20,8 +23,9 @@ source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" arch="" version="" +channel="" -args="$(getopt -o "" -l arch:,version: -- "$@")" +args="$(getopt -o "" -l arch:,version:,channel: -- "$@")" eval set -- "$args" while true; do case "$1" in @@ -33,6 +37,10 @@ while true; do version="$2" shift 2 ;; + --channel) + channel="$2" + shift 2 + ;; --) shift break @@ -45,7 +53,7 @@ done # Remove the "v" prefix because we don't want to add it twice. version="${version#v}" -if [[ "$version" == "" ]]; then +if [[ "$version" == "" ]] && [[ "$channel" == "" ]]; then version="$(execrelative ./version.sh)" fi @@ -60,6 +68,10 @@ if [[ "$version" == "latest" ]]; then tag="latest" fi +if [[ "$channel" != "" ]]; then + tag="$channel" +fi + if [[ "$arch" != "" ]]; then tag+="-$arch" fi From 1ca50d004020e969a0fe689157d5d47cf486b10d Mon Sep 17 00:00:00 2001 From: Zoupers Zou <1171443643@qq.com> Date: Wed, 9 Apr 2025 23:22:47 +0800 Subject: [PATCH 2/7] Update scripts/image_tag.sh Co-authored-by: Dean Sheather --- scripts/image_tag.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/image_tag.sh b/scripts/image_tag.sh index 25c7d538d34b8..382f5c8e9f3b7 100755 --- a/scripts/image_tag.sh +++ b/scripts/image_tag.sh @@ -11,7 +11,7 @@ # If no version is specified, defaults to the version from ./version.sh. If the # supplied version is "latest", no `v` prefix will be added to the tag. # -# The --channel parameter indecates the specific release channel, it's conflicts +# The --channel parameter indicates the specific release channel, it conflicts # with --version parameter. # # The returned tag will be sanitized to remove invalid characters like the plus From aeaf1baa4942b35298ac51d14e9dbc3254ad5464 Mon Sep 17 00:00:00 2001 From: Zoupers Zou <1171443643@qq.com> Date: Wed, 9 Apr 2025 23:22:57 +0800 Subject: [PATCH 3/7] Update .github/workflows/release.yaml Co-authored-by: Dean Sheather --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index cc0da91cc5bc0..b67e1c951c1e7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -496,7 +496,7 @@ jobs: # push image based on current channel ./scripts/build_docker_multiarch.sh \ --push \ - --target "$(./scripts/image_tag.sh --channel ${CODER_RELEASE_CHANNEL})" \ + --target "$(./scripts/image_tag.sh --channel "$CODER_RELEASE_CHANNEL")" \ $(cat build/coder_"$version"_linux_{amd64,arm64,armv7}.tag) env: CODER_BASE_IMAGE_TAG: ${{ steps.image-base-tag.outputs.tag }} From c30dda6a7ae5e62683290e8cb3218260f1d7fbc6 Mon Sep 17 00:00:00 2001 From: Zoupers Date: Wed, 9 Apr 2025 23:30:30 +0800 Subject: [PATCH 4/7] update according to suggestions --- .github/workflows/release.yaml | 2 +- scripts/image_tag.sh | 19 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b67e1c951c1e7..a73c661cf3225 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -496,7 +496,7 @@ jobs: # push image based on current channel ./scripts/build_docker_multiarch.sh \ --push \ - --target "$(./scripts/image_tag.sh --channel "$CODER_RELEASE_CHANNEL")" \ + --target "$(./scripts/image_tag.sh --version "$CODER_RELEASE_CHANNEL")" \ $(cat build/coder_"$version"_linux_{amd64,arm64,armv7}.tag) env: CODER_BASE_IMAGE_TAG: ${{ steps.image-base-tag.outputs.tag }} diff --git a/scripts/image_tag.sh b/scripts/image_tag.sh index 382f5c8e9f3b7..47858ae68411a 100755 --- a/scripts/image_tag.sh +++ b/scripts/image_tag.sh @@ -9,10 +9,7 @@ # the image tag for the multi-arch image will be returned instead. # # If no version is specified, defaults to the version from ./version.sh. If the -# supplied version is "latest", no `v` prefix will be added to the tag. -# -# The --channel parameter indicates the specific release channel, it conflicts -# with --version parameter. +# supplied version is one of "latest", "mainline", "stable", no `v` prefix will be added to the tag. # # The returned tag will be sanitized to remove invalid characters like the plus # sign. @@ -25,7 +22,7 @@ arch="" version="" channel="" -args="$(getopt -o "" -l arch:,version:,channel: -- "$@")" +args="$(getopt -o "" -l arch:,version: -- "$@")" eval set -- "$args" while true; do case "$1" in @@ -37,10 +34,6 @@ while true; do version="$2" shift 2 ;; - --channel) - channel="$2" - shift 2 - ;; --) shift break @@ -64,12 +57,8 @@ tag_prefix="${CODER_IMAGE_TAG_PREFIX:-}" tag="${tag_prefix:+$tag_prefix-}v$version" -if [[ "$version" == "latest" ]]; then - tag="latest" -fi - -if [[ "$channel" != "" ]]; then - tag="$channel" +if [[ "$version" == "latest" ]] || [[ "$version" == "mainline" ]] || [[ "$version" == "stable" ]]; then + tag="$version" fi if [[ "$arch" != "" ]]; then From b779f8370d82b4a3a8c77afdce89b17310958a01 Mon Sep 17 00:00:00 2001 From: Zoupers Date: Wed, 9 Apr 2025 23:58:24 +0800 Subject: [PATCH 5/7] left something... Signed-off-by: Zoupers --- scripts/image_tag.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/image_tag.sh b/scripts/image_tag.sh index 47858ae68411a..446fbe3ceeb3b 100755 --- a/scripts/image_tag.sh +++ b/scripts/image_tag.sh @@ -46,7 +46,7 @@ done # Remove the "v" prefix because we don't want to add it twice. version="${version#v}" -if [[ "$version" == "" ]] && [[ "$channel" == "" ]]; then +if [[ "$version" == "" ]]; then version="$(execrelative ./version.sh)" fi From cb447357e4dd901bf40e522509fa1214eb7905c6 Mon Sep 17 00:00:00 2001 From: Zoupers Date: Wed, 9 Apr 2025 23:59:08 +0800 Subject: [PATCH 6/7] left something... Signed-off-by: Zoupers --- scripts/image_tag.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/image_tag.sh b/scripts/image_tag.sh index 446fbe3ceeb3b..870e7e9a1ba30 100755 --- a/scripts/image_tag.sh +++ b/scripts/image_tag.sh @@ -20,7 +20,6 @@ source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" arch="" version="" -channel="" args="$(getopt -o "" -l arch:,version: -- "$@")" eval set -- "$args" From 6c705bf4fbb444754fbe7e380151fd199338a5de Mon Sep 17 00:00:00 2001 From: Zoupers Zou <1171443643@qq.com> Date: Thu, 10 Apr 2025 14:39:11 +0800 Subject: [PATCH 7/7] Update scripts/image_tag.sh Co-authored-by: Dean Sheather --- scripts/image_tag.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/image_tag.sh b/scripts/image_tag.sh index 870e7e9a1ba30..fb5f18f7a4b40 100755 --- a/scripts/image_tag.sh +++ b/scripts/image_tag.sh @@ -9,7 +9,8 @@ # the image tag for the multi-arch image will be returned instead. # # If no version is specified, defaults to the version from ./version.sh. If the -# supplied version is one of "latest", "mainline", "stable", no `v` prefix will be added to the tag. +# supplied version is one of "latest", "mainline", "stable", no `v` prefix will +# be added to the tag. # # The returned tag will be sanitized to remove invalid characters like the plus # sign.