forked from Jackiu1997/pure_live
-
Notifications
You must be signed in to change notification settings - Fork 151
308 lines (258 loc) · 10.7 KB
/
release.yml
File metadata and controls
308 lines (258 loc) · 10.7 KB
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
name: app-build-action
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for the release'
required: false
default: 'v1.0.0'
push:
tags:
- "v*"
jobs:
build-android:
runs-on: macos-latest
steps:
- name: 签出代码
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag_name || github.ref }}
- name: 下载Android keystore
id: android_keystore
uses: timheuer/base64-to-file@v1.2
with:
fileName: key.jks
encodedString: ${{ secrets.KEYSTORE_BASE64 }}
- name: 创建key.properties
run: |
echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" > android/key.properties
echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> android/key.properties
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties
- name: 设置JAVA环境
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: "17"
cache: 'gradle'
- name: 设置Flutter环境
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: 更新Flutter的packages
run: flutter pub get
- name: 打包APK
run: flutter build apk --release --split-per-abi
- name: 上传APK至Artifacts
uses: actions/upload-artifact@v4
with:
name: android-apks
path: |
build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk
build/app/outputs/flutter-apk/app-arm64-v8a-release.apk
build/app/outputs/flutter-apk/app-x86_64-release.apk
retention-days: 1
build-windows:
runs-on: windows-latest
steps:
- name: 签出代码
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag_name || github.ref }}
- name: Decode MSIX Certificate
shell: pwsh
run: |
$certBase64 = "${{ secrets.CERTIFICATE }}".Trim() -replace '\s+', ''
if ([string]::IsNullOrEmpty($certBase64)) { Write-Error "Secret is empty!"; exit 1 }
$certBytes = [System.Convert]::FromBase64String($certBase64)
# 使用絕對路徑並確保路徑格式一致
$certPath = Join-Path -Path (Get-Location) -ChildPath "certificate.pfx"
[IO.File]::WriteAllBytes($certPath, $certBytes)
# 將路徑存入環境變數供下一步使用(選用)
echo "FINAL_CERT_PATH=$certPath" >> $env:GITHUB_ENV
- name: Update make_config.yaml with real cert path
shell: pwsh
run: |
$configPath = "windows/packaging/msix/make_config.yaml"
# 獲取上一步生成的絕對路徑,並將反斜槓轉為正斜槓以避免 YAML 轉義問題
$absolutePath = "${{ env.FINAL_CERT_PATH }}".Replace('\', '/')
if (Test-Path $configPath) {
$content = Get-Content $configPath -Raw
# 正則替換:匹配 certificate_path: 後面跟隨的任何內容,替換為絕對路徑
$content = $content -replace 'certificate_path:\s*.*', "certificate_path: $absolutePath"
# 如果密碼也需要從 Secret 填入,可以在這裡一併處理
# $content = $content -replace 'certificate_password:\s*.*', 'certificate_password: ${{ secrets.CERT_PASSWORD }}'
Set-Content $configPath $content
Write-Host "Success: certificate_path set to $absolutePath"
} else {
Write-Error "Config file not found!"
exit 1
}
- name: 设置Flutter环境
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: 启用Flutter桌面支持
run: flutter config --enable-windows-desktop
- name: 更新Flutter的packages
run: flutter pub get
- name: Install Inno Setup 6
run: |
$url = "https://jrsoftware.org/download.php/is.exe"
$output = "${{ runner.temp }}\innosetup.exe"
Invoke-WebRequest -Uri $url -OutFile $output
Start-Process -FilePath $output -ArgumentList "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART" -Wait
echo "C:\Program Files (x86)\Inno Setup 6" >> $env:GITHUB_PATH
- name: Copy Chinese language pack
run: |
$source = "windows\packaging\exe\ChineseSimplified.isl"
$target = "C:\Program Files (x86)\Inno Setup 6\Languages\ChineseSimplified.isl"
if (Test-Path $source) { Copy-Item $source $target -Force }
- name: Install fastforge
run: dart pub global activate fastforge
- name: Get version from pubspec.yaml
id: get_version
shell: pwsh
run: |
$lines = Get-Content pubspec.yaml
foreach ($line in $lines) {
if ($line -match '^\s*version:\s*(\S+)') {
$v = $matches[1] -replace '[`"''`]', ''
"version=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
exit 0
}
}
Write-Error "Version not found"; exit 1
# 👇 关键修改:同时打包 exe 和 msix
- name: Package Windows (exe + msix)
run: fastforge package --platform windows --targets exe,msix
- name: Rename installers
shell: pwsh
env:
MSIX_CERT_PATH: ${{ env.MSIX_CERT_PATH }}
MSIX_CERT_PASSWORD: xxxx
run: |
$VERSION = "${{ steps.get_version.outputs.version }}"
$DIST_DIR = "dist"
# Find and rename .exe
$EXE_FILE = Get-ChildItem $DIST_DIR -Recurse -Filter "*.exe" | Select-Object -First 1
if ($EXE_FILE) {
Copy-Item $EXE_FILE.FullName "PureLive-$VERSION-windows-x64-setup.exe"
}
# Find and rename .msix
$MSIX_FILE = Get-ChildItem $DIST_DIR -Recurse -Filter "*.msix" | Select-Object -First 1
if ($MSIX_FILE) {
Copy-Item $MSIX_FILE.FullName "PureLive-$VERSION-windows-x64.msix"
}
- name: 上传Windows安装包(exe + msix)
uses: actions/upload-artifact@v4
with:
name: windows-installer
path: |
PureLive-${{ steps.get_version.outputs.version }}-windows-x64-setup.exe
PureLive-${{ steps.get_version.outputs.version }}-windows-x64.msix
retention-days: 1
build-macos:
runs-on: macos-latest
steps:
- name: 签出代码
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag_name || github.ref }}
- name: 设置Flutter环境
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: 更新Flutter的packages
run: flutter pub get
- name: Build macOS
run: flutter build macos --release -v
- name: Get version from pubspec.yaml
id: get_version
run: |
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //; s/[`"'"'"']//g')
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Install create-dmg
run: brew install create-dmg
- name: Create DMG
run: |
create-dmg \
--volname "PureLive" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--app-drop-link 600 185 \
"PureLive-${{ steps.get_version.outputs.version }}-macOS.dmg" \
"build/macos/Build/Products/Release/纯粹直播.app"
- name: 上传DMG
uses: actions/upload-artifact@v4
with:
name: macos-dmg
path: PureLive-${{ steps.get_version.outputs.version }}-macOS.dmg
retention-days: 1
publish-release:
runs-on: ubuntu-latest
needs: [build-android, build-windows, build-macos]
permissions:
contents: write
steps:
- name: 签出代码(用于读取 version.json)
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag_name || github.ref }}
- name: 下载所有构建产物
uses: actions/download-artifact@v4
with:
path: artifacts
- name: 读取版本描述
id: version
uses: juliangruber/read-file-action@v1
with:
path: assets/version.json
- name: 构建 Release Body
id: release_body
run: |
cat << 'EOF' > release_body.txt
# 纯粹直播 ${{ github.ref_name }}
开源无广告、无病毒,杀毒软件误报可自行斟酌使用。
### 📥 快速下载
|版本|下载地址|
|---|---|
|TV版|[pure_live_TV](https://github.com/liuchuancong/pure_live_TV/releases/latest)|
|Windows/macOS/Android版|[pure_live](https://github.com/liuchuancong/pure_live/releases/latest)|
### 🖥️ Windows 版
- **EXE 安装包**:适合所有用户,自动创建快捷方式
- **MSIX 包**:现代应用格式,支持干净卸载(需 Windows 10/11)
- 适配:Win10/11 (x64),自动创建桌面快捷方式
- 功能:多直播源、WebDAV、弹幕显示
- 快捷键:空格(播放/暂停) \| ESC(全屏切换) \| 上下键(音量) \| R(刷新)
### 🍎 macOS 版
感谢 RebornQ 开发 | 适配:macOS 10.15+ (x64) | 同 Windows 核心功能
### 📱 Android 版
适配:Android 6.0+ | 功能:WebDAV、多播放器切换、弹幕、应用内更新
### 📺 TV 版
适配:Android TV 6.0+ | 功能:直播源同步、多播放器、弹幕、应用内更新
### 📝 本次更新
${{ fromJson(steps.version.outputs.content).version_desc }}
EOF
echo "body_path=$(pwd)/release_body.txt" >> $GITHUB_OUTPUT
- name: 上传至 Release
uses: softprops/action-gh-release@v2.2.1
with:
name: ${{ github.event.inputs.tag_name || github.ref_name }}
body_path: ${{ steps.release_body.outputs.body_path }}
prerelease: false
token: ${{ secrets.TOKEN }}
files: |
artifacts/android-apks/app-armeabi-v7a-release.apk
artifacts/android-apks/app-arm64-v8a-release.apk
artifacts/android-apks/app-x86_64-release.apk
artifacts/windows-installer/*.exe
artifacts/windows-installer/*.msix
artifacts/macos-dmg/*.dmg
- name: 输出状态
if: always()
run: 'echo "✅ Release published with status: ${{ job.status }}"'