ci(gitea): split builds and retry artifact publication

This commit is contained in:
lingjhf committed 2026-10-06 14:04:09 +08:00
1 parent d83f94afd5
commit b225008476
18 files changed
+1790 -286

No files matched your search

+151 -30
View File
@@ -19,65 +19,185 @@ env:
GIT_CONFIG_KEY_1: core.eol
GIT_CONFIG_VALUE_1: lf
jobs:
build:
name: Windows x64 and Android
quality:
name: Check code and tests
runs-on: cutdex-windows-x64
env:
GITEA_ACTOR: lingjhf
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
steps:
- uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Check out source
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- name: Verify toolchains
- name: Configure persistent build caches
run: ./tool/gitea/prepare-build-cache.ps1
- name: Verify Flutter version and configure Java
run: |
$version = flutter --version --machine | ConvertFrom-Json
if ($version.frameworkVersion -ne '3.47.5') { throw 'Flutter 3.47.5 required.' }
flutter config --jdk-dir=$env:JAVA_HOME
if ($LASTEXITCODE -ne 0) { throw 'Flutter JDK setup failed.' }
- run: flutter pub get --enforce-lockfile
- run: dart analyze --fatal-infos
- run: flutter test --reporter expanded test packages/cutdex_ui/test packages/cutdex_native/test
- name: Validate update and release tooling
- name: Resolve locked Flutter dependencies
run: flutter pub get --enforce-lockfile
- name: Analyze Dart code
run: dart analyze --fatal-infos
- name: Run Flutter tests
run: flutter test --reporter expanded test packages/cutdex_ui/test packages/cutdex_native/test
- name: Test update and release tools
run: |
python -m unittest discover -s tool/gitea -p 'test_*.py'
if ($LASTEXITCODE -ne 0) { throw 'Release tooling tests failed.' }
python -m unittest discover -s tool/windows -p '*_unit.py'
if ($LASTEXITCODE -ne 0) { throw 'Update tooling tests failed.' }
- name: Bound Android build memory on the shared runner
android:
name: Build Android APK
needs: quality
runs-on: cutdex-windows-x64
env:
GITEA_ACTOR: lingjhf
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
steps:
- name: Check out source
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- name: Configure persistent build caches
run: ./tool/gitea/prepare-build-cache.ps1
- name: Verify Flutter version and configure Java
run: |
$version = flutter --version --machine | ConvertFrom-Json
if ($version.frameworkVersion -ne '3.47.5') { throw 'Flutter 3.47.5 required.' }
flutter config --jdk-dir=$env:JAVA_HOME
if ($LASTEXITCODE -ne 0) { throw 'Flutter JDK setup failed.' }
- name: Resolve locked Flutter dependencies
run: flutter pub get --enforce-lockfile
- name: Configure Gradle memory and build cache
run: |
$file = 'android/gradle.properties'
$properties = [IO.File]::ReadAllText($file).Replace('-Xmx8G', '-Xmx3G').Replace('MaxMetaspaceSize=4G', 'MaxMetaspaceSize=768m')
[IO.File]::WriteAllText($file, $properties + "`norg.gradle.workers.max=4`n")
- run: flutter build apk --release --flavor production --target-platform android-arm64,android-x64
- name: Build Windows from the pinned Gitea native release
[IO.File]::WriteAllText($file, $properties + "`norg.gradle.workers.max=4`norg.gradle.caching=true`n")
- name: Build production Android APK
run: flutter build apk --no-pub --release --flavor production --target-platform android-arm64,android-x64
- name: Upload Android CI artifact
uses: ./.gitea/actions/upload-artifact
with:
name: cutdex-android-build
path: build/app/outputs/flutter-apk/app-production-release.apk
compression-level: 0
retention-days: 30
windows-build:
name: Build Windows x64 app
needs: quality
runs-on: cutdex-windows-x64
env:
GITEA_ACTOR: lingjhf
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
steps:
- name: Check out source
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- name: Configure persistent build caches
run: ./tool/gitea/prepare-build-cache.ps1
- name: Verify Flutter version
run: |
$version = flutter --version --machine | ConvertFrom-Json
if ($version.frameworkVersion -ne '3.47.5') { throw 'Flutter 3.47.5 required.' }
- name: Resolve locked Flutter dependencies
run: flutter pub get --enforce-lockfile
- name: Build production Windows app
run: |
Remove-Item Env:CUTDEX_WINDOWS_PATH, Env:CUTDEX_WINDOWS_PACKAGE_PATH -ErrorAction SilentlyContinue
flutter build windows --release --flavor production
flutter build windows --no-pub --release --flavor production
if ($LASTEXITCODE -ne 0) { throw 'Windows build failed.' }
- name: Prepare isolated packaging tools
run: |
python -m venv .build/package-tools
if ($LASTEXITCODE -ne 0) { throw 'Packaging environment setup failed.' }
& ./.build/package-tools/Scripts/python.exe -m pip install pefile==2024.8.26
if ($LASTEXITCODE -ne 0) { throw 'Packaging dependency installation failed.' }
- uses: https://github.com/actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1
- name: Save Windows app for independent packaging retries
uses: ./.gitea/actions/upload-artifact
with:
name: cutdex-windows-app
path: |
build/windows/x64/production/runner/Release/
!build/windows/x64/production/runner/Release/**/processing/**
!build/windows/x64/production/runner/Release/**/*.pdb
!build/windows/x64/production/runner/Release/**/*.lib
!build/windows/x64/production/runner/Release/**/*.exp
!build/windows/x64/production/runner/Release/**/dartjni.dll
compression-level: 1
retention-days: 30
windows:
name: Audit and package Windows x64
needs: windows-build
runs-on: cutdex-windows-x64
steps:
- name: Check out source
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- name: Download saved Windows app
uses: https://github.com/actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: cutdex-windows-app
path: build/windows/x64/production/runner/Release/
- name: Set up .NET SDK
uses: https://github.com/actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1
with:
dotnet-version: '10.0.x'
- name: Install pinned Velopack release tool
- name: Prepare pinned packaging tools
run: ./tool/gitea/prepare-package-tools.ps1
- name: Audit and package Windows release
run: |
dotnet tool install vpk --version 1.2.161 --tool-path .build/vpk
if ($LASTEXITCODE -ne 0) { throw 'Velopack tool installation failed.' }
- name: Package application
& $env:PACKAGE_PYTHON tool/gitea/package-app.py --platform windows --vpk $env:VPK_PATH
if ($LASTEXITCODE -ne 0) { throw 'Windows packaging failed.' }
- name: Upload Windows CI artifact
uses: ./.gitea/actions/upload-artifact
with:
name: cutdex-windows-build
path: dist/*
compression-level: 0
retention-days: 30
build:
name: Assemble and validate CI artifacts
needs: [android, windows]
runs-on: cutdex-windows-x64
env:
GITEA_ACTOR: lingjhf
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
steps:
- name: Check out source
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- name: Download Android CI artifact
uses: https://github.com/actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: cutdex-android-build
path: build/app/outputs/flutter-apk/
- name: Download Windows CI artifact
uses: https://github.com/actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: cutdex-windows-build
path: .build/windows-packages/
- name: Validate packages and generate metadata
run: |
& ./.build/package-tools/Scripts/python.exe tool/gitea/package-app.py --vpk .build/vpk/vpk.exe
if ($LASTEXITCODE -ne 0) { throw 'Application packaging failed.' }
- name: Upload Android and Windows packages
uses: https://github.com/actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
python tool/gitea/package-app.py --platform assemble --windows-packages .build/windows-packages
if ($LASTEXITCODE -ne 0) { throw 'Application artifact validation failed.' }
- name: Upload combined CI artifact
uses: ./.gitea/actions/upload-artifact
with:
name: cutdex-release-packages
path: dist/*
if-no-files-found: error
compression-level: 0
retention-days: 30
- name: Upload release verification metadata
uses: ./.gitea/actions/upload-artifact
with:
name: cutdex-release-metadata
path: .build/release-metadata/*
compression-level: 0
retention-days: 30
checks:
name: Gitea CI passed
@@ -85,7 +205,8 @@ jobs:
needs: build
runs-on: cutdex-windows-x64
steps:
- env:
- name: Verify CI result
env:
RESULT: ${{ needs.build.result }}
run: |
if ($env:RESULT -ne 'success') { throw "App build: $env:RESULT" }