Skip to content

Commit

Permalink
feat(CI): 多平台构建和发布
Browse files Browse the repository at this point in the history
  • Loading branch information
hello8693 committed Aug 28, 2024
1 parent fdf981d commit 6d385aa
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 2 deletions.
30 changes: 28 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]

- name: Set up Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -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
65 changes: 65 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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

0 comments on commit 6d385aa

Please sign in to comment.