Browse Source

update release action

Signed-off-by: shanghaikid <jiangruiyi@gmail.com>
shanghaikid 8 months ago
parent
commit
4d684c6a69
2 changed files with 82 additions and 43 deletions
  1. 0 43
      .github/workflows/electron.yml
  2. 82 0
      .github/workflows/release.yml

+ 0 - 43
.github/workflows/electron.yml

@@ -1,43 +0,0 @@
-name: Build electron app
-
-on:
-  push:
-    tags:
-      - "*"
-
-jobs:
-  release:
-    runs-on: ${{ matrix.os }}
-
-    strategy:
-      matrix:
-        os: [macos-latest, ubuntu-latest, windows-latest]
-
-    steps:
-      - name: Check out Git repository
-        uses: actions/checkout@v4
-
-      - name: Install Node.js, NPM and Yarn
-        uses: actions/setup-node@v4
-        with:
-          node-version: 22
-
-      - name: Build client
-        run: |
-          cd client
-          yarn --network-timeout 100000
-          yarn build
-          cp -r build ../server
-
-      - name: Build/release Electron app
-        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 }}
-
-          # 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') }}

+ 82 - 0
.github/workflows/release.yml

@@ -0,0 +1,82 @@
+name: Build and Release Electron App and Docker Image
+
+on:
+  push:
+    tags:
+      - "*" # Triggers on any tag
+
+jobs:
+  build_and_release:
+    runs-on: ${{ matrix.os }}
+
+    strategy:
+      matrix:
+        os: [macos-latest, ubuntu-latest, windows-latest, docker]
+        include:
+          - os: docker
+            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
+        uses: actions/setup-node@v4
+        with:
+          node-version: 22
+
+      - name: Build client (only for non-Docker OS)
+        if: matrix.os != 'docker'
+        run: |
+          cd client
+          yarn --network-timeout 100000
+          yarn build
+          cp -r build ../server
+
+      - name: Build and Release Electron App
+        if: matrix.os != 'docker'
+        uses: samuelmeuli/action-electron-builder@v1
+        with:
+          package_root: "./server"
+          build_script_name: "build-electron"
+          github_token: ${{ secrets.GH_TOKEN }}
+          release: ${{ startsWith(github.ref, 'refs/tags/') }}
+
+      - name: Set up Docker Buildx (only for Docker job)
+        if: matrix.os == 'docker'
+        uses: docker/setup-buildx-action@v3
+
+      - name: Login to DockerHub (only for Docker job)
+        if: matrix.os == 'docker'
+        uses: docker/login-action@v1
+        with:
+          username: ${{ secrets.DOCKER_USERNAME }}
+          password: ${{ secrets.DOCKER_PWD }}
+
+      - name: Build and Push Docker Image
+        if: matrix.os == 'docker'
+        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
+
+  release_draft:
+    needs: build_and_release
+    runs-on: ubuntu-latest
+    if: ${{ startsWith(github.ref, 'refs/tags/') }}
+    steps:
+      - name: Create GitHub Release Draft
+        uses: actions/create-release@v1
+        with:
+          tag_name: ${{ github.ref_name }}
+          release_name: "Release ${{ github.ref_name }}"
+          draft: true
+          prerelease: false
+          token: ${{ secrets.GH_TOKEN }}