From 7041e628b7fcf41c9cfefc040ea40f63cee2ebf8 Mon Sep 17 00:00:00 2001 From: majinghe <42570491+majinghe@users.noreply.github.com> Date: Wed, 29 Apr 2026 11:23:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20docker=20image=20build=20and=20helm=20ch?= =?UTF-8?q?art=20publish=20error=20caused=20by=20versio=E2=80=A6=20(#2731)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/helm-package.yml | 50 ++++++++++++++++++++++++------ Dockerfile | 12 +++++++ Dockerfile.glibc | 15 +++++++-- helm/rustfs/Chart.yaml | 4 +-- 4 files changed, 67 insertions(+), 14 deletions(-) diff --git a/.github/workflows/helm-package.yml b/.github/workflows/helm-package.yml index cb21874c9..d808ee184 100644 --- a/.github/workflows/helm-package.yml +++ b/.github/workflows/helm-package.yml @@ -22,9 +22,6 @@ on: permissions: contents: read -env: - new_version: ${{ github.event.workflow_run.head_branch }} - jobs: build-helm-package: runs-on: ubicloud-standard-2 @@ -34,16 +31,47 @@ jobs: github.event.workflow_run.event == 'push' && contains(github.event.workflow_run.head_branch, '.') + outputs: + raw_tag: ${{ steps.version.outputs.raw_tag }} + version: ${{ steps.version.outputs.version }} + steps: - name: Checkout helm chart repo uses: actions/checkout@v6 + - name: Normalize release version + id: version + run: | + set -eux + + RAW="${{ github.event.workflow_run.head_branch }}" + + case "$RAW" in + refs/tags/*) + RAW_TAG="${RAW#refs/tags/}" + ;; + *) + RAW_TAG="$RAW" + ;; + esac + + VERSION="$RAW_TAG" + case "$VERSION" in + v*) + VERSION="${VERSION#v}" + ;; + esac + + echo "raw_tag=$RAW_TAG" >> "$GITHUB_OUTPUT" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + echo "raw_tag=$RAW_TAG" + echo "version=$VERSION" + - name: Replace chart app version run: | - set -e - set -x - old_version=$(grep "^appVersion:" helm/rustfs/Chart.yaml | awk '{print $2}') - sed -i "s/$old_version/$new_version/g" helm/rustfs/Chart.yaml + set -eux + sed -i -E 's/^appVersion:.*/appVersion: "${{ steps.version.outputs.version }}"/' helm/rustfs/Chart.yaml - name: Set up Helm uses: azure/setup-helm@v4.3.0 @@ -51,8 +79,9 @@ jobs: - name: Package Helm Chart run: | cp helm/README.md helm/rustfs/ - package_version=$(echo $new_version | awk -F '-' '{print $2}' | awk -F '.' '{print $NF}') - helm package ./helm/rustfs --destination helm/rustfs/ --version "0.0.$package_version" + helm package ./helm/rustfs \ + --destination helm/rustfs/ \ + --version "${{ steps.version.outputs.version }}" - name: Upload helm package as artifact uses: actions/upload-artifact@v6 @@ -64,6 +93,7 @@ jobs: publish-helm-package: runs-on: ubicloud-standard-2 needs: [ build-helm-package ] + if: needs.build-helm-package.result == 'success' steps: - name: Checkout helm package repo @@ -90,5 +120,5 @@ jobs: git config --global user.email "${{ secrets.EMAIL_ADDRESS }}" git status . git add . - git commit -m "Update rustfs helm package with $new_version." + git commit -m "Update rustfs helm package with ${{ needs.build-helm-package.outputs.version }}." git push origin main diff --git a/Dockerfile b/Dockerfile index 6e9ba21e7..88fc2c13e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,8 +29,20 @@ RUN set -eux; \ if [ "$RELEASE" = "latest" ]; then \ TAG="$(curl -fsSL https://api.github.com/repos/rustfs/rustfs/releases \ | grep -o '"tag_name": "[^"]*"' | cut -d'"' -f4 | head -n 1)"; \ + RELEASE_JSON="$(curl -fsSL "https://api.github.com/repos/rustfs/rustfs/releases/tags/$TAG")"; \ else \ TAG="$RELEASE"; \ + RELEASE_JSON="$(curl -fsSL "https://api.github.com/repos/rustfs/rustfs/releases/tags/$TAG" 2>/dev/null || true)"; \ + if [ -z "$RELEASE_JSON" ]; then \ + if [ "${TAG#v}" = "$TAG" ]; then \ + ALT_TAG="v$TAG"; \ + else \ + ALT_TAG="${TAG#v}"; \ + fi; \ + echo "Primary tag lookup failed, retrying with alternate tag: $ALT_TAG"; \ + RELEASE_JSON="$(curl -fsSL "https://api.github.com/repos/rustfs/rustfs/releases/tags/$ALT_TAG")"; \ + TAG="$ALT_TAG"; \ + fi; \ fi; \ echo "Using tag: $TAG (arch pattern: $ARCH_SUBSTR)"; \ # Find download URL in assets list for this tag that contains arch substring and ends with .zip diff --git a/Dockerfile.glibc b/Dockerfile.glibc index 0d06d71b0..344302b8e 100644 --- a/Dockerfile.glibc +++ b/Dockerfile.glibc @@ -31,14 +31,25 @@ RUN set -eux; \ arm64) ARCH_SUBSTR="aarch64-gnu" ;; \ *) echo "Unsupported TARGETARCH=$TARGETARCH" >&2; exit 1 ;; \ esac; \ - \ if [ "$RELEASE" = "latest" ]; then \ TAG="$(curl -fsSL https://api.github.com/repos/rustfs/rustfs/releases \ | grep -o '"tag_name": "[^"]*"' | cut -d'"' -f4 | head -n 1)"; \ + RELEASE_JSON="$(curl -fsSL "https://api.github.com/repos/rustfs/rustfs/releases/tags/$TAG")"; \ else \ TAG="$RELEASE"; \ + RELEASE_JSON="$(curl -fsSL "https://api.github.com/repos/rustfs/rustfs/releases/tags/$TAG" 2>/dev/null || true)"; \ + if [ -z "$RELEASE_JSON" ]; then \ + if [ "${TAG#v}" = "$TAG" ]; then \ + ALT_TAG="v$TAG"; \ + else \ + ALT_TAG="${TAG#v}"; \ + fi; \ + echo "Primary tag lookup failed, retrying with alternate tag: $ALT_TAG"; \ + RELEASE_JSON="$(curl -fsSL "https://api.github.com/repos/rustfs/rustfs/releases/tags/$ALT_TAG")"; \ + TAG="$ALT_TAG"; \ + fi; \ fi; \ - \ + echo "Using tag: $TAG (arch pattern: $ARCH_SUBSTR)"; \ URL="$(curl -fsSL "https://api.github.com/repos/rustfs/rustfs/releases/tags/$TAG" \ | grep -o "\"browser_download_url\": \"[^\"]*${ARCH_SUBSTR}[^\"]*\\.zip\"" \ | cut -d'"' -f4 | head -n 1)"; \ diff --git a/helm/rustfs/Chart.yaml b/helm/rustfs/Chart.yaml index 840695eed..12a54ea47 100644 --- a/helm/rustfs/Chart.yaml +++ b/helm/rustfs/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: rustfs description: RustFS helm chart to deploy RustFS on kubernetes cluster. type: application -version: "v1.0.0-beta.1" -appVersion: "v1.0.0-beta.1" +version: "1.0.0-beta.1" +appVersion: "1.0.0-beta.1" home: https://rustfs.com icon: https://media.sys.truenas.net/apps/rustfs/icons/icon.svg maintainers: