Skip to content

Commit 0d4fada

Browse files
committed
feat: add release ci
1 parent 4fcc93b commit 0d4fada

File tree

3 files changed

+121
-2
lines changed

3 files changed

+121
-2
lines changed

.github/workflows/release.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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

docs/record.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 发版
2+
3+
1. 先生成`CHANGELOG.md`
4+
5+
```shell
6+
npx changelogen@latest --release
7+
```
8+
9+
2. 提交`CHANGELOG.md`
10+
11+
```shell
12+
git push origin dev
13+
```
14+
15+
3. 提交`tag`
16+
17+
```shell
18+
git push --tags
19+
```

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
"version": "0.0.0",
55
"type": "module",
66
"scripts": {
7+
"preinstall": "npx only-allow pnpm",
78
"dev": "vite",
89
"build": "vue-tsc --noEmit && vite build",
910
"preview": "vite preview",
1011
"tauri": "tauri",
11-
"tauri dev": "pnpm tauri dev",
12-
"tauri build": "pnpm tauri build"
12+
"tauri dev": "tauri dev",
13+
"tauri build": "tauri build"
1314
},
1415
"dependencies": {
1516
"@tauri-apps/api": "^1",

0 commit comments

Comments
 (0)