From 3849bd68e8b793f7c0a5fd878888fd9b16ec238a Mon Sep 17 00:00:00 2001 From: zijiren233 Date: Mon, 9 Oct 2023 15:55:02 +0800 Subject: [PATCH] Fix: docker build args --- .github/workflows/release_docker.yml | 2 +- build.sh | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release_docker.yml b/.github/workflows/release_docker.yml index 095fb29..c430792 100644 --- a/.github/workflows/release_docker.yml +++ b/.github/workflows/release_docker.yml @@ -40,7 +40,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - build-args: | + build-args: VERSION="v${{ steps.get_version.outputs.VERSION }}" push: true tags: ${{ steps.meta.outputs.tags }} diff --git a/build.sh b/build.sh index 02fae51..c4cf372 100755 --- a/build.sh +++ b/build.sh @@ -47,7 +47,7 @@ function ParseArgs() { exit 0 ;; v) - VERSION="$OPTARG" + VERSION="$(echo "$OPTARG" | sed 's/ //g')" ;; w) WEB_VERSION="$OPTARG" @@ -99,22 +99,17 @@ function GetLatestWebVersion() { # Comply with golang version rules function CheckVersionFormat() { - if [ "$1" == "dev" ]; then - return 0 - fi - if [ "$(echo "$1" | grep -oE "^v?[0-9]+\.[0-9]+\.[0-9]+$")" ]; then + if [ "$1" == "dev" ] || [ "$(echo "$1" | grep -oE "^v?[0-9]+\.[0-9]+\.[0-9]+$")" ]; then return 0 + else + echo "version format error: $1" + exit 1 fi - return 1 } function FixArgs() { CheckAllPlatform CheckVersionFormat "$VERSION" - if [ $? -ne 0 ]; then - echo "version format error" - exit 1 - fi if [ ! "$WEB_VERSION" ]; then if [ "$VERSION" == "dev" ]; then WEB_VERSION="dev"