Browse Source

update release ci

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 8 months ago
parent
commit
2c5785c1b6
1 changed files with 43 additions and 12 deletions
  1. 43 12
      .github/workflows/release.yml

+ 43 - 12
.github/workflows/release.yml

@@ -1,43 +1,74 @@
-name: Build electron app
+name: Build and Release Electron App and Docker Image
 
 on:
   push:
     tags:
-      - "*"
+      - "*" # Triggers on any tag
 
 jobs:
-  release:
+  build_and_release:
     runs-on: ${{ matrix.os }}
 
     strategy:
       matrix:
-        os: [macos-latest, ubuntu-latest, windows-latest]
+        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
 
     steps:
       - name: Check out Git repository
         uses: actions/checkout@v4
 
-      - name: Install Node.js, NPM and Yarn
+      - name: Install Node.js, NPM, and Yarn
         uses: actions/setup-node@v4
         with:
           node-version: 22
 
-      - name: Build client
+      - name: Build client (only for non-Docker jobs)
+        if: matrix.name != 'Docker Build'
         run: |
           cd client
           yarn --network-timeout 100000
           yarn build
           cp -r build ../server
 
-      - name: Build/release Electron app
+      - name: Build and Release Electron App
+        if: matrix.name != 'Docker Build'
         uses: samuelmeuli/action-electron-builder@v1
         with:
           package_root: "./server"
           build_script_name: "build-electron"
-          # GitHub token, automatically provided to the action
-          # (No need to define this secret in the repo settings)
           github_token: ${{ secrets.GH_TOKEN }}
+          release: ${{ startsWith(github.ref, 'refs/tags/') }}
 
-          # If the commit is tagged with a version (e.g. "v1.0.0"),
-          # release the app after building
-          release: ${{ startsWith(github.ref, 'refs/tags/v') }}
+      - name: Set up Docker Buildx (only for Docker job)
+        if: matrix.name == 'Docker Build'
+        uses: docker/setup-buildx-action@v3
+
+      - name: Login to DockerHub (only for Docker job)
+        if: matrix.name == 'Docker Build'
+        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'
+        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
+          build-args: |
+            VERSION=${{ github.ref_name }}
+          push: true