77 description : ' Tag name for the release'
88 required : false
99 default : ' v1.0.0'
10+
1011 push :
1112 tags :
1213 - " v*"
1314
1415jobs :
16+
17+ # =========================================================
18+ # ANDROID
19+ # =========================================================
20+
1521 build-android :
1622 runs-on : macos-latest
23+
24+ strategy :
25+ matrix :
26+ branch : [master, fvp]
27+
1728 steps :
1829 - name : 签出代码
1930 uses : actions/checkout@v4
2031 with :
21- ref : ${{ github.event.inputs.tag_name || github.ref }}
32+ ref : ${{ matrix.branch }}
2233
2334 - name : 下载Android keystore
2435 id : android_keystore
@@ -47,62 +58,82 @@ jobs:
4758 channel : stable
4859 cache : true
4960
50- - name : 更新Flutter的packages
61+ - name : 更新Flutter packages
5162 run : flutter pub get
5263
53- - name : 打包APK
64+ - name : 打包 APK
5465 run : flutter build apk --release --split-per-abi
5566
56- - name : 上传APK至Artifacts
67+ - name : 重命名 APK
68+ shell : bash
69+ run : |
70+ cd build/app/outputs/flutter-apk
71+
72+ if [ "${{ matrix.branch }}" = "fvp" ]; then
73+ for f in app-*-release.apk; do
74+ mv "$f" "${f/-release.apk/-fvp.apk}"
75+ done
76+ fi
77+
78+ - name : 上传 APK
5779 uses : actions/upload-artifact@v4
5880 with :
59- name : android-apks
60- path : |
61- build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk
62- build/app/outputs/flutter-apk/app-arm64-v8a-release.apk
63- build/app/outputs/flutter-apk/app-x86_64-release.apk
81+ name : android-apks-${{ matrix.branch }}
82+ path : build/app/outputs/flutter-apk/*.apk
6483 retention-days : 1
6584
85+ # =========================================================
86+ # WINDOWS
87+ # =========================================================
88+
6689 build-windows :
6790 runs-on : windows-latest
91+
92+ strategy :
93+ matrix :
94+ branch : [master, fvp]
95+
6896 steps :
6997 - name : 签出代码
7098 uses : actions/checkout@v4
7199 with :
72- ref : ${{ github.event.inputs.tag_name || github.ref }}
73-
100+ ref : ${{ matrix.branch }}
101+
74102 - name : Decode MSIX Certificate
75103 shell : pwsh
76104 run : |
77105 $certBase64 = "${{ secrets.CERTIFICATE }}".Trim() -replace '\s+', ''
78- if ([string]::IsNullOrEmpty($certBase64)) { Write-Error "Secret is empty!"; exit 1 }
106+
107+ if ([string]::IsNullOrEmpty($certBase64)) {
108+ Write-Error "Secret is empty!"
109+ exit 1
110+ }
111+
79112 $certBytes = [System.Convert]::FromBase64String($certBase64)
80-
81- # 使用絕對路徑並確保路徑格式一致
113+
82114 $certPath = Join-Path -Path (Get-Location) -ChildPath "certificate.pfx"
115+
83116 [IO.File]::WriteAllBytes($certPath, $certBytes)
84-
85- # 將路徑存入環境變數供下一步使用(選用)
117+
86118 echo "FINAL_CERT_PATH=$certPath" >> $env:GITHUB_ENV
87119
88- - name : Update make_config.yaml with real cert path
120+ - name : Update make_config.yaml
89121 shell : pwsh
90122 run : |
91123 $configPath = "windows/packaging/msix/make_config.yaml"
92- # 獲取上一步生成的絕對路徑,並將反斜槓轉為正斜槓以避免 YAML 轉義問題
124+
93125 $absolutePath = "${{ env.FINAL_CERT_PATH }}".Replace('\', '/')
94-
126+
95127 if (Test-Path $configPath) {
96128 $content = Get-Content $configPath -Raw
97- # 正則替換:匹配 certificate_path: 後面跟隨的任何內容,替換為絕對路徑
129+
98130 $content = $content -replace 'certificate_path:\s*.*', "certificate_path: $absolutePath"
99-
100- # 如果密碼也需要從 Secret 填入,可以在這裡一併處理
101- # $content = $content -replace 'certificate_password:\s*.*', 'certificate_password: ${{ secrets.CERT_PASSWORD }}'
102-
131+
103132 Set-Content $configPath $content
133+
104134 Write-Host "Success: certificate_path set to $absolutePath"
105- } else {
135+ }
136+ else {
106137 Write-Error "Config file not found!"
107138 exit 1
108139 }
@@ -113,101 +144,137 @@ jobs:
113144 channel : stable
114145 cache : true
115146
116- - name : 启用Flutter桌面支持
147+ - name : 启用 Flutter Windows
117148 run : flutter config --enable-windows-desktop
118149
119- - name : 更新Flutter的packages
150+ - name : 更新Flutter packages
120151 run : flutter pub get
121152
122- - name : Install Inno Setup 6
153+ - name : Install Inno Setup
123154 run : |
124155 $url = "https://jrsoftware.org/download.php/is.exe"
125156 $output = "${{ runner.temp }}\innosetup.exe"
157+
126158 Invoke-WebRequest -Uri $url -OutFile $output
159+
127160 Start-Process -FilePath $output -ArgumentList "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART" -Wait
161+
128162 echo "C:\Program Files (x86)\Inno Setup 6" >> $env:GITHUB_PATH
129163
130164 - name : Copy Chinese language pack
131165 run : |
132166 $source = "windows\packaging\exe\ChineseSimplified.isl"
133167 $target = "C:\Program Files (x86)\Inno Setup 6\Languages\ChineseSimplified.isl"
134- if (Test-Path $source) { Copy-Item $source $target -Force }
168+
169+ if (Test-Path $source) {
170+ Copy-Item $source $target -Force
171+ }
135172
136173 - name : Install fastforge
137174 run : dart pub global activate fastforge
138-
139- - name : Get version from pubspec.yaml
175+
176+ - name : Get version
140177 id : get_version
141178 shell : pwsh
142179 run : |
143180 $lines = Get-Content pubspec.yaml
181+
144182 foreach ($line in $lines) {
145183 if ($line -match '^\s*version:\s*(\S+)') {
146184 $v = $matches[1] -replace '[`"''`]', ''
185+
147186 "version=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
187+
148188 exit 0
149189 }
150190 }
151- Write-Error "Version not found"; exit 1
152191
153- # 👇 关键修改:同时打包 exe 和 msix
154- - name : Package Windows (exe + msix)
192+ Write-Error "Version not found"
193+
194+ exit 1
195+
196+ - name : Package Windows
155197 run : fastforge package --platform windows --targets exe,msix
156198
157199 - name : Rename installers
158200 shell : pwsh
159- env :
160- MSIX_CERT_PATH : ${{ env.MSIX_CERT_PATH }}
161- MSIX_CERT_PASSWORD : xxxx
162201 run : |
163202 $VERSION = "${{ steps.get_version.outputs.version }}"
164203 $DIST_DIR = "dist"
165204
166- # Find and rename .exe
205+ $SUFFIX = ""
206+
207+ if ("${{ matrix.branch }}" -eq "fvp") {
208+ $SUFFIX = "-fvp"
209+ }
210+
211+ # EXE
167212 $EXE_FILE = Get-ChildItem $DIST_DIR -Recurse -Filter "*.exe" | Select-Object -First 1
213+
168214 if ($EXE_FILE) {
169- Copy-Item $EXE_FILE.FullName "PureLive-$VERSION-windows-x64-setup.exe"
215+ Copy-Item $EXE_FILE.FullName "PureLive-$VERSION$SUFFIX -windows-x64-setup.exe"
170216 }
171217
172- # Find and rename .msix
218+ # MSIX
173219 $MSIX_FILE = Get-ChildItem $DIST_DIR -Recurse -Filter "*.msix" | Select-Object -First 1
220+
174221 if ($MSIX_FILE) {
175- Copy-Item $MSIX_FILE.FullName "PureLive-$VERSION-windows-x64.msix"
222+ Copy-Item $MSIX_FILE.FullName "PureLive-$VERSION$SUFFIX -windows-x64.msix"
176223 }
177224
178- - name : 上传Windows安装包(exe + msix)
225+ - name : 上传 Windows 安装包
179226 uses : actions/upload-artifact@v4
180227 with :
181- name : windows-installer
228+ name : windows-installer-${{ matrix.branch }}
182229 path : |
183- PureLive-${{ steps.get_version.outputs.version }}-windows-x64-setup .exe
184- PureLive-${{ steps.get_version.outputs.version }}-windows-x64 .msix
230+ PureLive-* .exe
231+ PureLive-* .msix
185232 retention-days : 1
186233
234+ # =========================================================
235+ # MACOS
236+ # =========================================================
237+
187238 build-macos :
188239 runs-on : macos-latest
240+
241+ strategy :
242+ matrix :
243+ branch : [master, fvp]
244+
189245 steps :
190246 - name : 签出代码
191247 uses : actions/checkout@v4
192248 with :
193- ref : ${{ github.event.inputs.tag_name || github.ref }}
249+ ref : ${{ matrix.branch }}
250+
251+ - name : Set suffix
252+ id : suffix
253+ shell : bash
254+ run : |
255+ if [ "${{ matrix.branch }}" = "fvp" ]; then
256+ echo "suffix=-fvp" >> $GITHUB_OUTPUT
257+ else
258+ echo "suffix=" >> $GITHUB_OUTPUT
259+ fi
194260
195261 - name : 设置Flutter环境
196262 uses : subosito/flutter-action@v2
197263 with :
198264 channel : stable
199265 cache : true
200266
201- - name : 更新Flutter的packages
267+ - name : 更新Flutter packages
202268 run : flutter pub get
203269
204270 - name : Build macOS
205271 run : flutter build macos --release -v
206272
207- - name : Get version from pubspec.yaml
273+ - name : Get version
208274 id : get_version
209275 run : |
210276 VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //; s/[`"'"'"']//g')
277+
211278 echo "version=$VERSION" >> $GITHUB_OUTPUT
212279
213280 - name : Install create-dmg
@@ -221,26 +288,36 @@ jobs:
221288 --window-size 800 400 \
222289 --icon-size 100 \
223290 --app-drop-link 600 185 \
224- "PureLive-${{ steps.get_version.outputs.version }}-macOS.dmg" \
291+ "PureLive-${{ steps.get_version.outputs.version }}${{ steps.suffix.outputs.suffix }} -macOS.dmg" \
225292 "build/macos/Build/Products/Release/纯粹直播.app"
226293
227- - name : 上传DMG
294+ - name : 上传 DMG
228295 uses : actions/upload-artifact@v4
229296 with :
230- name : macos-dmg
231- path : PureLive-${{ steps.get_version.outputs.version }}-macOS .dmg
297+ name : macos-dmg-${{ matrix.branch }}
298+ path : PureLive-* .dmg
232299 retention-days : 1
233300
301+ # =========================================================
302+ # RELEASE
303+ # =========================================================
304+
234305 publish-release :
235306 runs-on : ubuntu-latest
236- needs : [build-android, build-windows, build-macos]
307+
308+ needs :
309+ - build-android
310+ - build-windows
311+ - build-macos
312+
237313 permissions :
238314 contents : write
315+
239316 steps :
240- - name : 签出代码(用于读取 version.json)
317+ - name : 签出代码
241318 uses : actions/checkout@v4
242319 with :
243- ref : ${{ github.event.inputs.tag_name || github.ref }}
320+ ref : master
244321
245322 - name : 下载所有构建产物
246323 uses : actions/download-artifact@v4
@@ -257,10 +334,10 @@ jobs:
257334 id : release_body
258335 run : |
259336 cat << 'EOF' > release_body.txt
337+
260338 # 纯粹直播 ${{ github.ref_name }}
261339
262- 开源无广告、无病毒,杀毒软件误报可自行斟酌使用。
263- ### 📥 快速下载
340+ ### 📥 快速下载
264341
265342 |版本|下载地址|
266343 |---|---|
@@ -284,24 +361,36 @@ jobs:
284361 适配:Android TV 6.0+ | 功能:直播源同步、多播放器、弹幕、应用内更新
285362
286363 ### 📝 本次更新
364+
287365 ${{ fromJson(steps.version.outputs.content).version_desc }}
366+
288367 EOF
368+
289369 echo "body_path=$(pwd)/release_body.txt" >> $GITHUB_OUTPUT
290370
291371 - name : 上传至 Release
292372 uses : softprops/action-gh-release@v2.2.1
293373 with :
294374 name : ${{ github.event.inputs.tag_name || github.ref_name }}
375+
295376 body_path : ${{ steps.release_body.outputs.body_path }}
377+
296378 prerelease : false
379+
297380 token : ${{ secrets.TOKEN }}
381+
298382 files : |
299- artifacts/android-apks/app-armeabi-v7a-release.apk
300- artifacts/android-apks/app-arm64-v8a-release.apk
301- artifacts/android-apks/app-x86_64-release.apk
302- artifacts/windows-installer/*.exe
303- artifacts/windows-installer/*.msix
304- artifacts/macos-dmg/*.dmg
383+ artifacts/android-apks-master/*.apk
384+ artifacts/android-apks-fvp/*.apk
385+
386+ artifacts/windows-installer-master/*.exe
387+ artifacts/windows-installer-master/*.msix
388+
389+ artifacts/windows-installer-fvp/*.exe
390+ artifacts/windows-installer-fvp/*.msix
391+
392+ artifacts/macos-dmg-master/*.dmg
393+ artifacts/macos-dmg-fvp/*.dmg
305394
306395 - name : 输出状态
307396 if : always()
0 commit comments