-
Notifications
You must be signed in to change notification settings - Fork 172
219 lines (195 loc) · 7.02 KB
/
beta_build.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: Build Beta Package
on:
schedule:
- cron: "22 22 * * *"
workflow_dispatch:
inputs:
updater:
description: "Enable updater?"
required: true
type: boolean
default: true
platform_windows:
description: "windows"
required: true
type: boolean
default: true
platform_linux:
description: "linux"
required: true
type: boolean
default: false
platform_macos:
description: "macos"
required: true
type: boolean
default: false
retain_days:
description: "Artifacts retention time (days)"
required: true
type: string
default: "1"
jobs:
preprocess:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.setting.outputs.matrix }}
retain_days: ${{ steps.setting.outputs.retain_days }}
file_prefix: ${{ steps.filename.outputs.file_prefix }}
# build_time: ${{ steps.filename.outputs.build_time }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install yq
uses: mikefarah/yq@master
with:
cmd: yq -V
- name: Update tauri.conf.json
if: ${{ github.event_name != 'schedule' && !inputs.updater }}
run: |
cp src-tauri/tauri.conf.json tauri.conf.json
yq -i '.bundle.createUpdaterArtifacts = false' tauri.conf.json
- name: Upload tauri-config
if: ${{ github.event_name != 'schedule' && !inputs.updater }}
uses: actions/upload-artifact@v4
with:
name: tauri-config
path: tauri.conf.json
retention-days: 1
- name: Get file name
id: filename
run: |
productName=$(yq e -r '.productName' src-tauri/tauri.conf.json)
# build_time=$(TZ=UTC-8 date +%y%m%d%H)
git_des=$(git describe --long --tags --always --dirty | sed 's/-g/-/')
echo "file_prefix=${productName}_${git_des}" >> "$GITHUB_OUTPUT"
# echo "build_time=${build_time}" >> "$GITHUB_OUTPUT"
- name: Setting variable
id: setting
run: |
matrix=""
if [ "${{ github.event_name }}" == "schedule" ]; then
matrix="\"windows-latest\",\"ubuntu-22.04\",\"macos-latest\""
retain_days='1'
else
if [ "${{ inputs.platform_windows }}" == "true" ]; then
matrix="${matrix}\"windows-latest\","
fi
if [ "${{ inputs.platform_linux }}" == "true" ]; then
matrix="${matrix}\"ubuntu-22.04\","
fi
if [ "${{ inputs.platform_macos }}" == "true" ]; then
matrix="${matrix}\"macos-latest\","
fi
if [ -z "${matrix}" ]; then
matrix="\"windows-latest\","
fi
matrix="${matrix%,}"
retain_days="${{ inputs.retain_days }}"
fi
echo "matrix=[${matrix}]" >> "$GITHUB_OUTPUT"
echo "retain_days=${retain_days}" >> "$GITHUB_OUTPUT"
auto-build:
needs: preprocess
permissions:
contents: write
strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.preprocess.outputs.matrix) }}
runs-on: ${{ matrix.os }}
env:
retain_days: ${{ needs.preprocess.outputs.retain_days }}
FILE_PREFIX: ${{ needs.preprocess.outputs.file_prefix }}
# BUILD_TIME: ${{ needs.preprocess.outputs.build_time }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
NO_STRIP: true
CI: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifact
if: ${{ github.event_name != 'schedule' && !inputs.updater }}
uses: actions/download-artifact@v4
with:
name: tauri-config
path: src-tauri
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: latest
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: "pnpm"
- name: Install dependencies (ubuntu only)
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
# 那些目标仅在 macos 运行器上使用,因此将其置于 `if` 语句中,以稍微加快 Windows 和 Linux 的构建速度。
targets: ${{ startsWith(matrix.os, 'macos') && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: "./src-tauri -> target"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build MacOS app
if: startsWith(matrix.os, 'macos')
run: |
pnpm tauri build --target aarch64-apple-darwin
pnpm tauri build --target x86_64-apple-darwin
- name: Build Other app
if: matrix.os == 'windows-latest' || matrix.os == 'ubuntu-22.04'
run: pnpm tauri build
- name: Rename macos
if: startsWith(matrix.os, 'macos')
run: |
mv target/aarch64-apple-darwin/release/bundle/dmg/*.dmg target/${{ env.FILE_PREFIX }}_aarch64.dmg
mv target/x86_64-apple-darwin/release/bundle/dmg/*.dmg target/${{ env.FILE_PREFIX }}_x64.dmg
- name: Rename windows
if: matrix.os == 'windows-latest'
run: mv target/release/bundle/nsis/*.exe target/${{ env.FILE_PREFIX }}_x64-setup.exe
- name: Rename linux
if: startsWith(matrix.os, 'ubuntu')
run: |
mv target/release/bundle/deb/*.deb target/${{ env.FILE_PREFIX }}_amd64.deb
mv target/release/bundle/rpm/*.rpm target/${{ env.FILE_PREFIX }}_x64.rpm
mv target/release/bundle/appimage/*.AppImage target/${{ env.FILE_PREFIX }}_amd64.AppImage
- name: Upload artifacts (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: ${{ env.FILE_PREFIX }}-windows_x64
path: target/*.exe
retention-days: ${{ env.retain_days}}
compression-level: 0
- name: Upload artifacts (MacOS)
if: startsWith(matrix.os, 'macos')
uses: actions/upload-artifact@v4
with:
name: ${{ env.FILE_PREFIX }}-macos_x64_aarch64
path: target/*.dmg
retention-days: ${{ env.retain_days}}
compression-level: 0
- name: Upload artifacts (Linux)
if: startsWith(matrix.os, 'ubuntu')
uses: actions/upload-artifact@v4
with:
name: ${{ env.FILE_PREFIX }}-linux_amd64
path: |
target/*.deb
target/*.rpm
target/*.AppImage
retention-days: ${{ env.retain_days}}
compression-level: 0