Pin Flutter with FVM and share local environment loading across IDE, Python, and Dart entrypoints. Keep CI on the verified preinstalled SDK and skip local overrides. Extract common build presets, process execution, and file hashing. Propagate project roots through SDK selection and release commands, and migrate macOS release, signing, and DMG orchestration to Python. Reuse local check suites in CI, support Android source overrides, and update documentation and regression tests.
245 lines
10 KiB
YAML
245 lines
10 KiB
YAML
name: Gitea CI
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
defaults:
|
|
run:
|
|
shell: pwsh
|
|
concurrency:
|
|
group: app-${{ gitea.ref }}
|
|
cancel-in-progress: true
|
|
env:
|
|
CI: 'true'
|
|
PYTHONUTF8: '1'
|
|
CUTDEX_GITEA_INTERNAL_URL: http://127.0.0.1:3000
|
|
GIT_CONFIG_COUNT: '2'
|
|
GIT_CONFIG_KEY_0: core.autocrlf
|
|
GIT_CONFIG_VALUE_0: 'false'
|
|
GIT_CONFIG_KEY_1: core.eol
|
|
GIT_CONFIG_VALUE_1: lf
|
|
jobs:
|
|
quality:
|
|
name: Check code and tests
|
|
runs-on: cutdex-windows-x64
|
|
outputs:
|
|
build-app: ${{ steps.scope.outputs.build-app }}
|
|
package-app: ${{ steps.scope.outputs.package-app }}
|
|
env:
|
|
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
|
|
steps:
|
|
- name: Check out source
|
|
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
with:
|
|
persist-credentials: false
|
|
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
|
fetch-depth: 0
|
|
- name: Select compilation and packaging scope
|
|
id: scope
|
|
env:
|
|
CI_EVENT_NAME: ${{ gitea.event_name }}
|
|
CI_PR_BASE_SHA: ${{ gitea.event.pull_request.base.sha }}
|
|
CI_PR_HEAD_SHA: ${{ gitea.event.pull_request.head.sha }}
|
|
run: |
|
|
python tool/gitea/ci_scope.py
|
|
if ($LASTEXITCODE -ne 0) { throw 'CI scope selection failed.' }
|
|
- name: Prepare Flutter environment
|
|
uses: ./.gitea/actions/prepare-flutter
|
|
with:
|
|
configure-java: 'true'
|
|
- name: Analyze Dart code
|
|
run: python tool/check.py --suite analyze
|
|
- name: Run Flutter tests
|
|
run: python tool/check.py --suite flutter
|
|
- name: Check repository and tool tests
|
|
run: python tool/check.py --suite tools
|
|
|
|
android:
|
|
name: Build Android APK
|
|
needs: quality
|
|
if: ${{ needs.quality.outputs.build-app == 'true' }}
|
|
runs-on: cutdex-windows-x64
|
|
env:
|
|
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
|
|
steps:
|
|
- name: Check out source
|
|
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
with:
|
|
persist-credentials: false
|
|
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
|
- name: Prepare Flutter environment
|
|
uses: ./.gitea/actions/prepare-flutter
|
|
with:
|
|
configure-java: 'true'
|
|
- 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`norg.gradle.caching=true`n")
|
|
- name: Build production Android APK
|
|
env:
|
|
GITEA_ACTOR: lingjhf
|
|
run: |
|
|
Remove-Item Env:CUTDEX_ANDROID_PATH -ErrorAction SilentlyContinue
|
|
python tool/build.py android
|
|
if ($LASTEXITCODE -ne 0) { throw 'Android build failed.' }
|
|
- name: Upload Android CI artifact
|
|
if: ${{ needs.quality.outputs.package-app == 'true' }}
|
|
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
|
|
if: ${{ needs.quality.outputs.build-app == 'true' }}
|
|
runs-on: cutdex-windows-x64
|
|
env:
|
|
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
|
|
steps:
|
|
- name: Check out source
|
|
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
with:
|
|
persist-credentials: false
|
|
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
|
- name: Prepare Flutter environment
|
|
uses: ./.gitea/actions/prepare-flutter
|
|
- name: Build production Windows app
|
|
run: |
|
|
Remove-Item Env:CUTDEX_WINDOWS_PATH, Env:CUTDEX_WINDOWS_PACKAGE_PATH -ErrorAction SilentlyContinue
|
|
python tool/build.py windows
|
|
if ($LASTEXITCODE -ne 0) { throw 'Windows build failed.' }
|
|
- name: Verify native SDK matches pinned packaging tools
|
|
run: |
|
|
python tool/windows/windows_updates.py verify-sdk
|
|
if ($LASTEXITCODE -ne 0) { throw 'Windows native SDK version validation failed.' }
|
|
- name: Save Windows app for independent packaging retries
|
|
if: ${{ needs.quality.outputs.package-app == 'true' }}
|
|
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: [quality, windows-build]
|
|
if: ${{ needs.quality.outputs.package-app == 'true' }}
|
|
runs-on: cutdex-windows-x64
|
|
steps:
|
|
- name: Check out source
|
|
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
with:
|
|
persist-credentials: false
|
|
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
|
- name: Download saved Windows app
|
|
uses: https://github.com/actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
|
env:
|
|
ACTIONS_RESULTS_URL: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
|
with:
|
|
name: cutdex-windows-app
|
|
path: build/windows/x64/production/runner/Release/
|
|
- name: Prepare Windows packaging environment
|
|
uses: ./.gitea/actions/prepare-windows-packaging
|
|
- name: Audit and package Windows release
|
|
run: |
|
|
& $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: [quality, android, windows]
|
|
if: ${{ needs.quality.outputs.package-app == 'true' }}
|
|
runs-on: cutdex-windows-x64
|
|
steps:
|
|
- name: Check out source
|
|
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
with:
|
|
persist-credentials: false
|
|
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
|
- name: Download Android CI artifact
|
|
uses: https://github.com/actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
|
env:
|
|
ACTIONS_RESULTS_URL: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
|
with:
|
|
name: cutdex-android-build
|
|
path: build/app/outputs/flutter-apk/
|
|
- name: Download Windows CI artifact
|
|
uses: https://github.com/actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
|
env:
|
|
ACTIONS_RESULTS_URL: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
|
with:
|
|
name: cutdex-windows-build
|
|
path: .build/windows-packages/
|
|
- name: Validate packages and generate metadata
|
|
run: |
|
|
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/*
|
|
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
|
|
if: always()
|
|
needs: [quality, android, windows-build, windows, build]
|
|
runs-on: cutdex-windows-x64
|
|
steps:
|
|
- name: Verify CI result
|
|
env:
|
|
QUALITY_RESULT: ${{ needs.quality.result }}
|
|
BUILD_APP: ${{ needs.quality.outputs.build-app }}
|
|
PACKAGE_APP: ${{ needs.quality.outputs.package-app }}
|
|
# The local runner omits results for jobs excluded by their condition.
|
|
# Required jobs still fail below if this becomes 'skipped'.
|
|
ANDROID_RESULT: ${{ needs.android.result || 'skipped' }}
|
|
WINDOWS_BUILD_RESULT: ${{ needs.windows-build.result || 'skipped' }}
|
|
WINDOWS_PACKAGE_RESULT: ${{ needs.windows.result || 'skipped' }}
|
|
ASSEMBLY_RESULT: ${{ needs.build.result || 'skipped' }}
|
|
run: |
|
|
if ($env:QUALITY_RESULT -ne 'success') { throw "Code checks: $env:QUALITY_RESULT" }
|
|
if ($env:BUILD_APP -notin @('true', 'false') -or $env:PACKAGE_APP -notin @('true', 'false')) {
|
|
throw 'Missing or invalid CI scope outputs.'
|
|
}
|
|
if ($env:PACKAGE_APP -eq 'true' -and $env:BUILD_APP -ne 'true') { throw 'Packaging requires compilation.' }
|
|
$compileResult = if ($env:BUILD_APP -eq 'true') { 'success' } else { 'skipped' }
|
|
$packageResult = if ($env:PACKAGE_APP -eq 'true') { 'success' } else { 'skipped' }
|
|
$jobs = @(
|
|
@{ Name = 'Android compilation'; Result = $env:ANDROID_RESULT; Expected = $compileResult },
|
|
@{ Name = 'Windows compilation'; Result = $env:WINDOWS_BUILD_RESULT; Expected = $compileResult },
|
|
@{ Name = 'Windows packaging'; Result = $env:WINDOWS_PACKAGE_RESULT; Expected = $packageResult },
|
|
@{ Name = 'Artifact assembly'; Result = $env:ASSEMBLY_RESULT; Expected = $packageResult }
|
|
)
|
|
foreach ($job in $jobs) {
|
|
if ($job.Result -ne $job.Expected) { throw "$($job.Name): $($job.Result), expected $($job.Expected)." }
|
|
}
|