From 6d385aa20b1384e798b1f49bf1632ab02fe51ab3 Mon Sep 17 00:00:00 2001 From: hello8693 <1320998105@qq.com> Date: Wed, 28 Aug 2024 18:51:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(CI):=20=E5=A4=9A=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E5=92=8C=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yaml | 30 ++++++++++++++-- .github/workflows/publish.yaml | 65 ++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6cd1a9c..38da96a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -4,15 +4,17 @@ on: [ push ] jobs: build: - runs-on: windows-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: [ windows-latest, macos-latest, ubuntu-latest ] node-version: [ 20.x ] steps: - name: Checkout uses: actions/checkout@v4.1.7 + - name: Set up Node.js uses: actions/setup-node@v4 with: @@ -22,10 +24,34 @@ jobs: run: yarn install - name: Build and package for Windows + if: matrix.os == 'windows-latest' run: yarn build:win - - name: Upload artifact + - name: Build and package for macOS + if: matrix.os == 'macos-latest' + run: yarn build:mac + + - name: Build and package for Linux + if: matrix.os == 'ubuntu-latest' + run: yarn build:linux + + - name: Upload artifact for Windows + if: matrix.os == 'windows-latest' uses: actions/upload-artifact@v4 with: name: ExamShowboard-Windows path: dist/*.exe + + - name: Upload artifact for macOS + if: matrix.os == 'macos-latest' + uses: actions/upload-artifact@v4 + with: + name: ExamShowboard-macOS + path: dist/*.dmg + + - name: Upload artifact for Linux + if: matrix.os == 'ubuntu-latest' + uses: actions/upload-artifact@v4 + with: + name: ExamShowboard-Linux + path: dist/*.AppImage diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..e54b08b --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,65 @@ +name: Build and Package Electron App on Release + +on: + release: + types: [published] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [windows-latest, macos-latest, ubuntu-latest] + node-version: [20.x] + + steps: + - name: Checkout + uses: actions/checkout@v4.1.7 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: yarn install + + - name: Build and package for Windows + if: matrix.os == 'windows-latest' + run: yarn build:win + + - name: Build and package for macOS + if: matrix.os == 'macos-latest' + run: yarn build:mac + + - name: Build and package for Linux + if: matrix.os == 'ubuntu-latest' + run: yarn build:linux + + - name: Upload artifact for Windows + if: matrix.os == 'windows-latest' + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: dist/*.exe + asset_name: ExamShowboard-Windows.exe + asset_content_type: application/octet-stream + + - name: Upload artifact for macOS + if: matrix.os == 'macos-latest' + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: dist/*.dmg + asset_name: ExamShowboard-macOS.dmg + asset_content_type: application/octet-stream + + - name: Upload artifact for Linux + if: matrix.os == 'ubuntu-latest' + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: dist/*.AppImage + asset_name: ExamShowboard-Linux.AppImage + asset_content_type: application/octet-stream