refactor(ci): unify build environment initialization
Gitea CI / Check code and tests (pull_request) Successful in 6m19s
Gitea CI / Build Windows x64 app (pull_request) Successful in 3m12s
Gitea CI / Build Android APK (pull_request) Successful in 3m39s
Gitea CI / Audit and package Windows x64 (pull_request) Successful in 1m4s
Gitea CI / Assemble and validate CI artifacts (pull_request) Successful in 50s
Gitea CI / Gitea CI passed (pull_request) Successful in 2s
Gitea CI / Check code and tests (pull_request) Successful in 6m19s
Gitea CI / Build Windows x64 app (pull_request) Successful in 3m12s
Gitea CI / Build Android APK (pull_request) Successful in 3m39s
Gitea CI / Audit and package Windows x64 (pull_request) Successful in 1m4s
Gitea CI / Assemble and validate CI artifacts (pull_request) Successful in 50s
Gitea CI / Gitea CI passed (pull_request) Successful in 2s
This commit is contained in:
1 parent
da98df00a8
commit
5a0ffa513c
4 files changed
+92
-46
No files matched your search
@@ -14,6 +14,19 @@ enabled for CI. Do not clear these caches between runs. Each job must have its o
|
|||||||
checkout; do not share a Flutter `build/` or `.dart_tool/` directory between jobs.
|
checkout; do not share a Flutter `build/` or `.dart_tool/` directory between jobs.
|
||||||
With an ephemeral runner, these user directories must be persisted separately.
|
With an ephemeral runner, these user directories must be persisted separately.
|
||||||
|
|
||||||
|
The local `prepare-flutter` action owns cache setup, Flutter version validation,
|
||||||
|
optional Java configuration and locked dependency resolution for the quality,
|
||||||
|
Android and Windows compilation jobs. `FLUTTER_VERSION` is declared once in the
|
||||||
|
CI workflow. The separate `prepare-windows-packaging` action owns the user .NET
|
||||||
|
installation and packaging tool setup, so packaging retries do not resolve
|
||||||
|
Flutter dependencies. Individual setup steps remain visible within each action.
|
||||||
|
|
||||||
|
Workflow-level environment variables contain only shared nonsecret settings.
|
||||||
|
The SDK token is limited to quality and platform compilation jobs. The fixed
|
||||||
|
Maven account name is set only on the Android build step, matching the SDK token
|
||||||
|
owner rather than the user who triggered CI. Assembly needs no SDK credentials;
|
||||||
|
Release credentials remain confined to the Release workflow's publishing jobs.
|
||||||
|
|
||||||
Build commands keep Flutter's default Pub preparation after the explicit locked
|
Build commands keep Flutter's default Pub preparation after the explicit locked
|
||||||
resolution. Do not use `--no-pub`: Flutter also regenerates release plugin
|
resolution. Do not use `--no-pub`: Flutter also regenerates release plugin
|
||||||
registrants in that preparation, removing dev-only plugins such as integration_test.
|
registrants in that preparation, removing dev-only plugins such as integration_test.
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
name: Prepare Flutter build environment
|
||||||
|
description: Configure persistent caches, verify Flutter and resolve locked dependencies.
|
||||||
|
inputs:
|
||||||
|
flutter-version:
|
||||||
|
description: Required Flutter framework version
|
||||||
|
required: true
|
||||||
|
configure-java:
|
||||||
|
description: Configure Flutter to use the runner's JAVA_HOME
|
||||||
|
default: 'false'
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Configure persistent build caches
|
||||||
|
shell: pwsh
|
||||||
|
run: ./tool/gitea/prepare-build-cache.ps1
|
||||||
|
- name: Verify Flutter version
|
||||||
|
shell: pwsh
|
||||||
|
env:
|
||||||
|
REQUIRED_FLUTTER_VERSION: ${{ inputs.flutter-version }}
|
||||||
|
run: |
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$output = flutter --version --machine
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw 'Cannot read Flutter version.' }
|
||||||
|
$version = $output | ConvertFrom-Json
|
||||||
|
if ($version.frameworkVersion -ne $env:REQUIRED_FLUTTER_VERSION) {
|
||||||
|
throw "Flutter $env:REQUIRED_FLUTTER_VERSION required; found $($version.frameworkVersion)."
|
||||||
|
}
|
||||||
|
- name: Configure Flutter Java
|
||||||
|
if: ${{ inputs.configure-java == 'true' }}
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
if (-not $env:JAVA_HOME) { throw 'JAVA_HOME is required for Flutter JDK setup.' }
|
||||||
|
flutter config --jdk-dir=$env:JAVA_HOME
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw 'Flutter JDK setup failed.' }
|
||||||
|
- name: Resolve locked Flutter dependencies
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
flutter pub get --enforce-lockfile
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw 'Locked Flutter dependency resolution failed.' }
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
name: Prepare Windows packaging environment
|
||||||
|
description: Reuse the user .NET installation and pinned packaging tools independently of Flutter.
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Configure user .NET installation
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$directory = Join-Path $env:LOCALAPPDATA 'Cutdex/ci-tools/dotnet'
|
||||||
|
[IO.Directory]::CreateDirectory($directory) | Out-Null
|
||||||
|
"DOTNET_INSTALL_DIR=$directory" | Out-File -LiteralPath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
|
"DOTNET_ROOT=$directory" | Out-File -LiteralPath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
|
- name: Set up .NET SDK
|
||||||
|
uses: https://github.com/actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1
|
||||||
|
with:
|
||||||
|
dotnet-version: '10.0.x'
|
||||||
|
- name: Prepare pinned packaging tools
|
||||||
|
shell: pwsh
|
||||||
|
run: ./tool/gitea/prepare-package-tools.ps1
|
||||||
+19
-46
@@ -13,6 +13,7 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
env:
|
env:
|
||||||
PYTHONUTF8: '1'
|
PYTHONUTF8: '1'
|
||||||
|
FLUTTER_VERSION: '3.47.5'
|
||||||
CUTDEX_GITEA_INTERNAL_URL: http://127.0.0.1:3000
|
CUTDEX_GITEA_INTERNAL_URL: http://127.0.0.1:3000
|
||||||
GIT_CONFIG_COUNT: '2'
|
GIT_CONFIG_COUNT: '2'
|
||||||
GIT_CONFIG_KEY_0: core.autocrlf
|
GIT_CONFIG_KEY_0: core.autocrlf
|
||||||
@@ -24,7 +25,6 @@ jobs:
|
|||||||
name: Check code and tests
|
name: Check code and tests
|
||||||
runs-on: cutdex-windows-x64
|
runs-on: cutdex-windows-x64
|
||||||
env:
|
env:
|
||||||
GITEA_ACTOR: lingjhf
|
|
||||||
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
|
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out source
|
- name: Check out source
|
||||||
@@ -32,16 +32,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
- name: Configure persistent build caches
|
- name: Prepare Flutter environment
|
||||||
run: ./tool/gitea/prepare-build-cache.ps1
|
uses: ./.gitea/actions/prepare-flutter
|
||||||
- name: Verify Flutter version and configure Java
|
with:
|
||||||
run: |
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||||
$version = flutter --version --machine | ConvertFrom-Json
|
configure-java: 'true'
|
||||||
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: Analyze Dart code
|
- name: Analyze Dart code
|
||||||
run: dart analyze --fatal-infos
|
run: dart analyze --fatal-infos
|
||||||
- name: Run Flutter tests
|
- name: Run Flutter tests
|
||||||
@@ -58,7 +53,6 @@ jobs:
|
|||||||
needs: quality
|
needs: quality
|
||||||
runs-on: cutdex-windows-x64
|
runs-on: cutdex-windows-x64
|
||||||
env:
|
env:
|
||||||
GITEA_ACTOR: lingjhf
|
|
||||||
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
|
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out source
|
- name: Check out source
|
||||||
@@ -66,22 +60,19 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
- name: Configure persistent build caches
|
- name: Prepare Flutter environment
|
||||||
run: ./tool/gitea/prepare-build-cache.ps1
|
uses: ./.gitea/actions/prepare-flutter
|
||||||
- name: Verify Flutter version and configure Java
|
with:
|
||||||
run: |
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||||
$version = flutter --version --machine | ConvertFrom-Json
|
configure-java: 'true'
|
||||||
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
|
- name: Configure Gradle memory and build cache
|
||||||
run: |
|
run: |
|
||||||
$file = 'android/gradle.properties'
|
$file = 'android/gradle.properties'
|
||||||
$properties = [IO.File]::ReadAllText($file).Replace('-Xmx8G', '-Xmx3G').Replace('MaxMetaspaceSize=4G', 'MaxMetaspaceSize=768m')
|
$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")
|
[IO.File]::WriteAllText($file, $properties + "`norg.gradle.workers.max=4`norg.gradle.caching=true`n")
|
||||||
- name: Build production Android APK
|
- name: Build production Android APK
|
||||||
|
env:
|
||||||
|
GITEA_ACTOR: lingjhf
|
||||||
run: flutter build apk --release --flavor production --target-platform android-arm64,android-x64
|
run: flutter build apk --release --flavor production --target-platform android-arm64,android-x64
|
||||||
- name: Upload Android CI artifact
|
- name: Upload Android CI artifact
|
||||||
uses: ./.gitea/actions/upload-artifact
|
uses: ./.gitea/actions/upload-artifact
|
||||||
@@ -96,7 +87,6 @@ jobs:
|
|||||||
needs: quality
|
needs: quality
|
||||||
runs-on: cutdex-windows-x64
|
runs-on: cutdex-windows-x64
|
||||||
env:
|
env:
|
||||||
GITEA_ACTOR: lingjhf
|
|
||||||
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
|
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out source
|
- name: Check out source
|
||||||
@@ -104,14 +94,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
- name: Configure persistent build caches
|
- name: Prepare Flutter environment
|
||||||
run: ./tool/gitea/prepare-build-cache.ps1
|
uses: ./.gitea/actions/prepare-flutter
|
||||||
- name: Verify Flutter version
|
with:
|
||||||
run: |
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||||
$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
|
- name: Build production Windows app
|
||||||
run: |
|
run: |
|
||||||
Remove-Item Env:CUTDEX_WINDOWS_PATH, Env:CUTDEX_WINDOWS_PACKAGE_PATH -ErrorAction SilentlyContinue
|
Remove-Item Env:CUTDEX_WINDOWS_PATH, Env:CUTDEX_WINDOWS_PACKAGE_PATH -ErrorAction SilentlyContinue
|
||||||
@@ -152,18 +138,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: cutdex-windows-app
|
name: cutdex-windows-app
|
||||||
path: build/windows/x64/production/runner/Release/
|
path: build/windows/x64/production/runner/Release/
|
||||||
- name: Configure user .NET installation
|
- name: Prepare Windows packaging environment
|
||||||
run: |
|
uses: ./.gitea/actions/prepare-windows-packaging
|
||||||
$directory = Join-Path $env:LOCALAPPDATA 'Cutdex/ci-tools/dotnet'
|
|
||||||
[IO.Directory]::CreateDirectory($directory) | Out-Null
|
|
||||||
"DOTNET_INSTALL_DIR=$directory" | Out-File -LiteralPath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
||||||
"DOTNET_ROOT=$directory" | Out-File -LiteralPath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
||||||
- name: Set up .NET SDK
|
|
||||||
uses: https://github.com/actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1
|
|
||||||
with:
|
|
||||||
dotnet-version: '10.0.x'
|
|
||||||
- name: Prepare pinned packaging tools
|
|
||||||
run: ./tool/gitea/prepare-package-tools.ps1
|
|
||||||
- name: Audit and package Windows release
|
- name: Audit and package Windows release
|
||||||
run: |
|
run: |
|
||||||
& $env:PACKAGE_PYTHON tool/gitea/package-app.py --platform windows --vpk $env:VPK_PATH
|
& $env:PACKAGE_PYTHON tool/gitea/package-app.py --platform windows --vpk $env:VPK_PATH
|
||||||
@@ -180,9 +156,6 @@ jobs:
|
|||||||
name: Assemble and validate CI artifacts
|
name: Assemble and validate CI artifacts
|
||||||
needs: [android, windows]
|
needs: [android, windows]
|
||||||
runs-on: cutdex-windows-x64
|
runs-on: cutdex-windows-x64
|
||||||
env:
|
|
||||||
GITEA_ACTOR: lingjhf
|
|
||||||
CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out source
|
- name: Check out source
|
||||||
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||||
|
|||||||
Reference in new issue
Block a user