Files
cutdex/.gitea/BUILD_AND_RELEASE.md
T
lingjhf 0343e2f723 refactor(build): unify SDK configuration and release tooling
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.
2026-10-06 23:34:15 +08:00

5.6 KiB

Gitea Windows and Android builds

The Windows x64 host runner needs the Flutter version pinned in .fvmrc, Python, Node, Visual Studio C++, JDK 21 and Android SDK 36. The native cutdex_windows Release and cutdex_android Maven packages must be published before building this app. The SDK Git dependency is pinned to Gitea; the runner account needs SSH access to that private repository.

Set CUTDEX_GITEA_TOKEN in repository Actions Secrets with repository read and package read access. It authenticates private Gitea native package downloads. The Android APK includes ARM64 and x86_64, uses the production flavor and currently uses the project's debug signing configuration. Configure formal signing before shipping a production signed Android release. The Windows ZIP includes the whole Flutter Release directory and passes the PE dependency audit. Processing workers and optional models are separate; these four repositories contain no worker bundle.

CI and local checks share tool/check.py suites for analysis, app/package tests and repository/tool tests. Local tooling loads .env.local with the project FVM SDK; CI uses its version-verified preinstalled SDK and ignores that file. Both use tool/build.py production/release presets for platform compilation.

CI always analyzes and tests the app. Ordinary code PRs also compile both platforms, but skip Windows packaging, artifact uploads and final assembly. Documentation-only PRs skip platform compilation as well. PR changes to CI, tooling, native platform configuration, package dependencies or app update code run the complete pipeline. ci_scope.py compares the PR base and head using Git history, including deleted files; a failed comparison fails code checks. Main pushes and manual CI runs always execute the complete pipeline and upload cutdex-release-packages including SHA256SUMS and a release manifest. They also save cutdex-release-metadata containing only the manifest, checksums, Windows update index and audit report. Platform, complete and metadata artifacts retain 30 days. Protect main with Gitea CI / Gitea CI passed (pull_request). This required check validates every expected job and permits skipped jobs only when the selected scope explicitly excludes them; failures, cancellations and unexpected skips fail it.

Windows compilation and packaging are separate jobs. Full-pipeline compilation saves the unpackaged Release directory as cutdex-windows-app for 30 days; packaging downloads it and runs the existing PE audit and Velopack tools. Rerunning a failed packaging job reuses this app without recompiling. Assembly and Release jobs similarly reuse their upstream artifacts. Use the failed-job rerun option: a whole-workflow rerun executes compilation again. A job always restarts from its first step. Saving the Windows app adds one artifact transfer between the jobs.

CI artifact uploads attempt at most three times, waiting 5 and 15 seconds between attempts and replacing incomplete artifacts of the same job-owned name. Release attachment uploads use the same bounded delays for temporary HTTP/network errors, and check for already saved filenames before repeating a POST. Permanent errors fail immediately and final attachment byte verification remains required. If the Windows app cannot be saved after all attempts, its build job still needs to be rerun. Draft creation and final publication are not automatically retried.

After main CI succeeds, create v at that exact commit, or manually dispatch the Release workflow with the existing tag. Release preparation selects a successful main ci.yml run for the exact tagged commit and requires unexpired cutdex-android-build, cutdex-windows-build and cutdex-release-metadata artifacts. It creates a draft bound to both that commit and that CI run. Release jobs never rebuild the app or reinstall Flutter dependencies.

Android and Windows independently download their platform artifacts from the selected CI run and immediately upload them to the draft. These jobs run in parallel. The final job accepts only the compact metadata artifact from that same CI run. Complete binary archives cannot substitute for platform packages or metadata. Missing, expired or duplicate required artifacts block preparation before any draft is created. Platform uploads check attachment presence without reading back their bytes. Before publication, every attachment is read back once and verified against trusted SHA256 checksums; the full update package also matches its index SHA1 and size. Upload and verification batches use at most two requests per job. Verification reads in 1 MiB chunks. Tag, CI, draft and attachment ID/name bindings are rechecked before the Release is made public.

A failed upload leaves the draft unpublished with successful uploads retained. Manual dispatch with the same tag resumes the original CI run, even if another CI for that commit has since succeeded. Matching attachments are reused; changed or unrelated attachments block publication rather than being replaced. If the original platform or metadata artifacts have expired, release preparation fails and requires operator attention. Published Releases are never overwritten. The built-in GITEA_TOKEN handles release writes and Actions artifact reads; no separate release-write PAT is required. Do not commit credentials or keystores.

Full-pipeline CI produces Actions artifacts without creating Releases. If a tag is pushed before main CI succeeds, release preparation fails without creating a draft; retry the Release workflow once CI has finished. This design overlaps platform uploads, not main CI builds with Release uploads. There is no legacy whole-archive promotion entry point or format fallback.