This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# build.yml | ||
name: Build | ||
on: | ||
push: | ||
tags: | ||
- 'v*' # 在推送的标签以"v"开头时执行 | ||
jobs: | ||
release: | ||
name: build and release electron app | ||
runs-on: ${{ matrix.os }} # 使用矩阵策略来确定操作系统 | ||
strategy: | ||
fail-fast: false | ||
matrix: # 这个定义会启用2个系统进行打包 | ||
os: [windows-latest, macos-latest, ubuntu-latest] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
# 安装 node | ||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
# 安装 pnpm | ||
- name: Install Pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
# 安装 包 | ||
- name: Install Dependencies | ||
run: pnpm install | ||
# 打包 | ||
- name: Build Electron App | ||
run: pnpm run build:desktop | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} | ||
- name: Cleanup Artifacts for Windows | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
npx rimraf "packages/desktop/release/!(*.exe)" | ||
- name: Cleanup Artifacts for MacOS | ||
if: matrix.os == 'macos-latest' | ||
run: | | ||
npx rimraf "packages/desktop/release/!(*.dmg)" | ||
- name: upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.os }} | ||
path: packages/desktop/release | ||
- name: release | ||
uses: softprops/action-gh-release@v2 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: 'packages/desktop/release/**' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} |