Browse Source

Update release.yml

ryjiang 8 months ago
parent
commit
616698da18
1 changed files with 34 additions and 31 deletions
  1. 34 31
      .github/workflows/release.yml

+ 34 - 31
.github/workflows/release.yml

@@ -11,16 +11,7 @@ jobs:
 
     strategy:
       matrix:
-        include:
-          - os: macos-latest
-            name: "macOS Build"
-          - os: ubuntu-latest
-            name: "Ubuntu Build"
-          - os: windows-latest
-            name: "Windows Build"
-          - os: ubuntu-latest
-            name: "Docker Build"
-            platform: linux/amd64,linux/arm64,linux/arm/v7
+        os: [macos-latest, ubuntu-latest, windows-latest]
 
     steps:
       - name: Check out Git repository
@@ -32,7 +23,6 @@ jobs:
           node-version: 22
 
       - name: Build client (only for non-Docker jobs)
-        if: matrix.name != 'Docker Build'
         run: |
           cd client
           yarn --network-timeout 100000
@@ -40,7 +30,6 @@ jobs:
           cp -r build ../server
 
       - name: Build and Release Electron App
-        if: matrix.name != 'Docker Build'
         uses: samuelmeuli/action-electron-builder@v1
         with:
           package_root: "./server"
@@ -48,41 +37,55 @@ jobs:
           github_token: ${{ secrets.GH_TOKEN }}
           release: ${{ startsWith(github.ref, 'refs/tags/') }}
 
-      - name: Set up Docker Buildx (only for Docker job)
-        if: matrix.name == 'Docker Build'
+  # Job to build each Docker platform separately
+  docker_build:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        platform: [linux/amd64, linux/arm64, linux/arm/v7]
+
+    steps:
+      - name: Check out Git repository
+        uses: actions/checkout@v4
+
+      - name: Set up Docker Buildx
         uses: docker/setup-buildx-action@v3
 
-      - name: Login to DockerHub (only for Docker job)
-        if: matrix.name == 'Docker Build'
+      - name: Login to DockerHub
         uses: docker/login-action@v1
         with:
           username: ${{ secrets.DOCKER_USERNAME }}
           password: ${{ secrets.DOCKER_PWD }}
 
-      - name: Build and Push Docker Image
-        if: matrix.name == 'Docker Build'
+      - name: Build and Push Docker Image for ${{ matrix.platform }}
         uses: docker/build-push-action@v5
         with:
           context: .
           platforms: ${{ matrix.platform }}
           tags: |
-            zilliz/attu:${{ github.ref_name }}
-          cache-from: type=registry,ref=zilliz/attu:cache
-          cache-to: type=inline
+            zilliz/attu:${{ github.ref_name }}-${{ matrix.platform }}
           build-args: |
             VERSION=${{ github.ref_name }}
           push: true
 
-  release_draft:
-    needs: build_and_release
+  # Job to combine platform-specific tags into one multi-platform tag
+  docker_manifest:
+    needs: docker_build
     runs-on: ubuntu-latest
-    if: ${{ startsWith(github.ref, 'refs/tags/') }}
     steps:
-      - name: Create GitHub Release Draft
-        uses: actions/create-release@v1
+      - name: Install Docker CLI
+        run: sudo apt-get update && sudo apt-get install -y docker.io
+
+      - name: Login to DockerHub
+        uses: docker/login-action@v1
         with:
-          tag_name: ${{ github.ref_name }}
-          release_name: "Release ${{ github.ref_name }}"
-          draft: true
-          prerelease: false
-          token: ${{ secrets.GH_TOKEN }}
+          username: ${{ secrets.DOCKER_USERNAME }}
+          password: ${{ secrets.DOCKER_PWD }}
+
+      - name: Create and Push Docker Manifest
+        run: |
+          docker manifest create zilliz/attu:${{ github.ref_name }} \
+            --amend zilliz/attu:${{ github.ref_name }}-linux/amd64 \
+            --amend zilliz/attu:${{ github.ref_name }}-linux/arm64 \
+            --amend zilliz/attu:${{ github.ref_name }}-linux/arm/v7
+          docker manifest push zilliz/attu:${{ github.ref_name }}