-
Notifications
You must be signed in to change notification settings - Fork 1
170 lines (145 loc) · 4.25 KB
/
build-and-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: 构建和发布
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: write
jobs:
build:
name: 在 ${{ matrix.os }} 上构建 ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
target: windows
- os: macos-latest
target: macos-modern
- os: macos-latest
target: macos-bigsur
steps:
- uses: actions/checkout@v3
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: 缓存 pnpm 依赖项
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: 安装依赖
run: pnpm install
- name: 缓存 Cargo 注册表
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: 缓存 Cargo 构建目录
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: 安装 Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: 安装 macOS 构建目标
if: matrix.os == 'macos-latest'
run: |
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
- name: 设置环境变量(针对 macOS Big Sur)
if: matrix.target == 'macos-bigsur'
run: echo "MACOSX_DEPLOYMENT_TARGET=10.13" >> $GITHUB_ENV
- name: 构建 Tauri 应用 (现代 macOS)
if: matrix.target == 'macos-modern'
uses: tauri-apps/tauri-action@v1.4.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: --target "universal-apple-darwin"
includeDebug: false
- name: 构建 Tauri 应用 (Big Sur)
if: matrix.target == 'macos-bigsur'
uses: tauri-apps/tauri-action@v1.4.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: --target x86_64-apple-darwin
config: |
{
"tauri": {
"bundle": {
"macOS": {
"minimumSystemVersion": "10.13",
"targets": ["x86_64-apple-darwin"]
}
}
}
}
- name: 构建 Tauri 应用 (Windows)
if: matrix.target == 'windows'
uses: tauri-apps/tauri-action@v1.4.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 上传构建产物
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}-build
path: |
src-tauri/target/release/bundle/**/*
src-tauri/target/release/*.app.zip
release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: 获取版本
id: package-version
shell: bash
run: |
version=$(pnpm pkg get version | tr -d '"')
echo "Version: $version"
echo "version=$version" >> $GITHUB_OUTPUT
- name: 下载所有构建产物
uses: actions/download-artifact@v3
with:
path: artifacts
- name: 列出下载的构建产物
shell: bash
run: |
ls -R artifacts/
- name: 发布到 GitHub Releases
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.package-version.outputs.version }}
name: 发布 v${{ steps.package-version.outputs.version }}
files: artifacts/**/*.*
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}