1+ # 可选,将显示在 GitHub 存储库的“操作”选项卡中的工作流名称
2+ name : Release CI
3+
4+ # 指定此工作流的触发器
5+ on :
6+ push :
7+ # 匹配特定标签 (refs/tags)
8+ tags :
9+ - " v*" # 推送事件匹配 v*, 例如 v1.0,v20.15.10 等来触发工作流
10+ workflow_dispatch :
11+
12+ jobs :
13+ create-release :
14+ runs-on : ubuntu-latest
15+ steps :
16+ - uses : actions/checkout@v4
17+ with :
18+ fetch-depth : 0
19+ - name : Set output
20+ id : vars
21+ run : echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
22+
23+ # 安装 Node.js
24+ - name : Setup node
25+ uses : actions/setup-node@v4
26+ with :
27+ node-version : 20
28+
29+ # 发布 Release,使用自定义名称
30+ - name : Generate changelog
31+ id : create_release
32+ run : npx changelogithub --draft --name ${{ steps.vars.outputs.tag }}
33+ env :
34+ GITHUB_TOKEN : ${{ secrets.RELEASE_TOKEN }}
35+
36+ # 编译 Tauri
37+ build-app :
38+ needs : create-release
39+ permissions :
40+ contents : write
41+ strategy :
42+ fail-fast : false
43+ matrix :
44+ # platform: [macos-latest, macos-12, windows-latest, ubuntu-20.04]
45+ platform : [windows-latest]
46+ runs-on : ${{ matrix.platform }}
47+
48+ steps :
49+ - name : Checkout repository
50+ uses : actions/checkout@v4
51+ - name : Setup node
52+ uses : actions/setup-node@v4
53+ with :
54+ node-version : 20
55+ - uses : pnpm/action-setup@v3
56+ with :
57+ version : latest
58+
59+ - name : install dependencies (ubuntu only)
60+ if : matrix.platform == 'ubuntu-20.04'
61+ run : |
62+ sudo apt-get update
63+ sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev patchelf
64+
65+ # 安装 Rust
66+ - name : Install Rust stable
67+ uses : dtolnay/rust-toolchain@stable
68+
69+ # 使用 Rust 缓存,加快安装速度
70+ - name : Rust cache
71+ uses : swatinem/rust-cache@v2
72+ with :
73+ workspaces : ./src-tauri -> target
74+
75+ # 获取 pnpm 缓存
76+ - name : Sync node version and setup cache
77+ uses : actions/setup-node@v4
78+ with :
79+ node-version : 20
80+ cache : pnpm
81+
82+ # 安装依赖, 前端打包
83+ - name : Install app dependencies and build web
84+ run : pnpm install --frozen-lockfile
85+
86+ # 执行构建,以及推送 github release
87+ - name : Build the app
88+ uses : tauri-apps/tauri-action@v0
89+
90+ env :
91+ GITHUB_TOKEN : ${{ secrets.RELEASE_TOKEN }}
92+ # TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
93+ # TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
94+ with :
95+ tagName : ${{ github.ref_name }}
96+ releaseName : EcoPaste ${{ needs.create-release.outputs.APP_VERSION }}
97+ releaseBody : " "
98+ releaseDraft : true
99+ prerelease : false
0 commit comments