From 0f6097f58f13bb6e83bc23b9978e06a0e0976b73 Mon Sep 17 00:00:00 2001 From: lingjhf Date: Tue, 6 Oct 2026 03:03:03 +0800 Subject: [PATCH 01/11] Build Android and Windows packages and promote Gitea releases --- .gitea/workflows/ci.yml | 61 +++++++++++++++++++++++ .gitea/workflows/release.yml | 32 ++++++++++++ pubspec.lock | 54 ++++++++++---------- pubspec.yaml | 4 +- tool/gitea/package-app.py | 41 +++++++++++++++ tool/gitea/promote-release.py | 94 +++++++++++++++++++++++++++++++++++ 6 files changed, 257 insertions(+), 29 deletions(-) create mode 100644 .gitea/workflows/ci.yml create mode 100644 .gitea/workflows/release.yml create mode 100644 tool/gitea/package-app.py create mode 100644 tool/gitea/promote-release.py diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..0c30f92 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,61 @@ +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: + PYTHONUTF8: '1' + 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: + build: + name: Windows x64 and Android + runs-on: cutdex-windows-x64 + env: + GITEA_ACTOR: lingjhf + CUTDEX_GITEA_TOKEN: ${{ secrets.CUTDEX_GITEA_TOKEN }} + steps: + - uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + persist-credentials: false + - name: Verify toolchains + 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 + - run: flutter build apk --release --flavor production --target-platform android-arm64,android-x64 + - run: flutter build windows --release --flavor production + - name: Package application + run: python tool/gitea/package-app.py + - name: Upload Android and Windows packages + uses: https://github.com/actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: cutdex-release-packages + path: dist/* + if-no-files-found: error + retention-days: 30 + checks: + name: Gitea CI passed + if: always() + needs: build + runs-on: cutdex-windows-x64 + steps: + - env: + RESULT: ${{ needs.build.result }} + run: | + if ($env:RESULT -ne 'success') { throw "App build: $env:RESULT" } diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..f9fc108 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,32 @@ +name: Gitea Release +on: + push: + tags: ['v*'] + workflow_dispatch: + inputs: + tag: + description: Existing release tag matching pubspec version + required: true +permissions: + contents: write +concurrency: + group: cutdex-release + cancel-in-progress: false +jobs: + release: + runs-on: cutdex-windows-x64 + steps: + - uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + ref: ${{ gitea.event.inputs.tag || gitea.ref_name }} + persist-credentials: false + - name: Publish validated Android and Windows packages + shell: pwsh + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + GITEA_REPOSITORY: ${{ gitea.repository }} + RELEASE_TAG: ${{ gitea.event.inputs.tag || gitea.ref_name }} + run: | + $env:GITEA_SHA = git rev-parse HEAD + python tool/gitea/promote-release.py + if ($LASTEXITCODE -ne 0) { throw 'Release promotion failed.' } diff --git a/pubspec.lock b/pubspec.lock index ce4c4d5..26aeaad 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -214,81 +214,81 @@ packages: dependency: transitive description: path: "packages/editor" - ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - resolved-ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - url: "git@github.com:lingjhf/cutdex_sdk.git" + ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" cutdex_mcp: dependency: transitive description: path: "packages/mcp" - ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - resolved-ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - url: "git@github.com:lingjhf/cutdex_sdk.git" + ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" cutdex_preview: dependency: transitive description: path: "packages/preview" - ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - resolved-ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - url: "git@github.com:lingjhf/cutdex_sdk.git" + ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" cutdex_project: dependency: transitive description: path: "packages/project" - ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - resolved-ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - url: "git@github.com:lingjhf/cutdex_sdk.git" + ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" cutdex_runtime: dependency: transitive description: path: "packages/runtime" - ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - resolved-ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - url: "git@github.com:lingjhf/cutdex_sdk.git" + ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.0.1" cutdex_sdk: dependency: "direct main" description: path: "." - ref: "v0.1.0" - resolved-ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - url: "git@github.com:lingjhf/cutdex_sdk.git" + ref: be8f891 + resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" cutdex_timeline: dependency: transitive description: path: "packages/timeline" - ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - resolved-ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - url: "git@github.com:lingjhf/cutdex_sdk.git" + ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.2.0" cutdex_timeline_ui: dependency: transitive description: path: "packages/timeline_ui" - ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - resolved-ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - url: "git@github.com:lingjhf/cutdex_sdk.git" + ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" cutdex_tools: dependency: transitive description: path: "packages/tools" - ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - resolved-ref: "113eee1d63d546470db5d5d4f0d4aa0c312e7cac" - url: "git@github.com:lingjhf/cutdex_sdk.git" + ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" dart_style: diff --git a/pubspec.yaml b/pubspec.yaml index 375d80b..8cfe1b6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -24,8 +24,8 @@ dependencies: cutdex_sdk: git: - url: git@github.com:lingjhf/cutdex_sdk.git - ref: v0.1.0 + url: ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git + ref: be8f891 cutdex_agent: git: url: https://github.com/cutdex-ai/cutdex_agent.git diff --git a/tool/gitea/package-app.py b/tool/gitea/package-app.py new file mode 100644 index 0000000..b1459b2 --- /dev/null +++ b/tool/gitea/package-app.py @@ -0,0 +1,41 @@ +"""Package the Windows Release directory and Android production APK.""" +import hashlib +import json +from pathlib import Path +import re +import shutil +import zipfile + +ROOT = Path(__file__).resolve().parents[2] + + +def main(): + version = re.search(r'^version: (\S+)', (ROOT / 'pubspec.yaml').read_text(), re.M)[1].split('+')[0] + output = ROOT / 'dist' + output.mkdir(exist_ok=True) + apk = ROOT / 'build/app/outputs/flutter-apk/app-production-release.apk' + windows = ROOT / 'build/windows/x64/runner/Release' + if not apk.is_file() or not (windows / 'cutdex.exe').is_file(): + raise ValueError('Both production builds are required') + with zipfile.ZipFile(apk) as archive: + names = archive.namelist() + for abi in ('arm64-v8a', 'x86_64'): + if f'lib/{abi}/libflutter.so' not in names: + raise ValueError(f'APK missing Flutter ABI: {abi}') + if any(name.startswith('lib/armeabi-v7a/') for name in names): + raise ValueError('APK must use supported 64-bit ABIs only') + shutil.copyfile(apk, output / f'cutdex-{version}-android.apk') + package = output / f'cutdex-{version}-windows-x64.zip' + with zipfile.ZipFile(package, 'w', compression=zipfile.ZIP_DEFLATED) as archive: + for path in sorted(windows.rglob('*')): + if path.is_file() and path.suffix.lower() not in ('.pdb', '.lib', '.exp'): + archive.write(path, f'cutdex-{version}/' + path.relative_to(windows).as_posix()) + files = sorted(output.glob('*.apk')) + sorted(output.glob('*.zip')) + manifest = {path.name: hashlib.file_digest(path.open('rb'), 'sha256').hexdigest() for path in files} + (output / 'SHA256SUMS').write_text(''.join(f'{digest} {name}\n' for name, digest in manifest.items())) + (output / 'release-manifest.json').write_text(json.dumps({'version': version, 'files': manifest, 'androidSigning': 'debug', 'processingWorkersBundled': False}, indent=2) + '\n') + print(json.dumps(manifest, indent=2)) + + +if __name__ == '__main__': + main() diff --git a/tool/gitea/promote-release.py b/tool/gitea/promote-release.py new file mode 100644 index 0000000..058c8ad --- /dev/null +++ b/tool/gitea/promote-release.py @@ -0,0 +1,94 @@ +"""Promote packages from a successful main CI for the exact release commit.""" +import hashlib +import io +import json +import os +from pathlib import Path +import re +import urllib.error +import urllib.parse +import urllib.request +import uuid +import zipfile + +SERVER = 'https://git.orangraph.com' +REPO = os.environ['GITEA_REPOSITORY'] +TOKEN = os.environ['GITEA_TOKEN'] +BASE = f'{SERVER}/api/v1/repos/{REPO}' + + +def request(url, data=None, method=None, content_type='application/json'): + headers = {'Authorization': f'token {TOKEN}'} + if data is not None: + headers['Content-Type'] = content_type + if isinstance(data, dict): + data = json.dumps(data).encode() + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=300) as response: + body = response.read() + return json.loads(body) if 'application/json' in response.headers.get('Content-Type', '') else body + + +def download(asset): + url = urllib.parse.urlparse(asset['browser_download_url']) + if url.hostname != 'git.orangraph.com': + raise ValueError('Unexpected attachment host') + return request(urllib.parse.urlunparse(url._replace(scheme='https', netloc='git.orangraph.com'))) + + +def main(): + sha = os.environ['GITEA_SHA'] + tag = os.environ['RELEASE_TAG'] + version = re.search(r'^version: (\S+)', Path('pubspec.yaml').read_text(), re.M)[1].split('+')[0] + if tag != f'v{version}': + raise ValueError('Release tag must match pubspec version') + runs = request(f'{BASE}/actions/runs?limit=100')['workflow_runs'] + matches = [run for run in runs if run['head_sha'] == sha and run['head_branch'] == 'main' and run['conclusion'] == 'success' and run['name'] == 'Gitea CI'] + if not matches: + raise ValueError('No successful main CI for this exact commit; run CI before releasing') + run = max(matches, key=lambda item: item['id']) + artifacts = request(f"{BASE}/actions/runs/{run['id']}/artifacts")['artifacts'] + found = [item for item in artifacts if item['name'] == 'cutdex-release-packages' and not item.get('expired', False)] + if len(found) != 1: + raise ValueError('Expected one validated application artifact') + data = request(f"{BASE}/actions/artifacts/{found[0]['id']}/zip") + with zipfile.ZipFile(io.BytesIO(data)) as archive: + contents = {item.filename: archive.read(item) for item in archive.infolist() if not item.is_dir()} + manifest = json.loads(contents['release-manifest.json']) + if manifest['version'] != version: + raise ValueError('Artifact version does not match release') + expected = {f'cutdex-{version}-android.apk', f'cutdex-{version}-windows-x64.zip'} + if set(manifest['files']) != expected: + raise ValueError('Release requires both Android and Windows packages') + for name, digest in manifest['files'].items(): + if hashlib.sha256(contents[name]).hexdigest() != digest: + raise ValueError(f'Package checksum mismatch: {name}') + releases = request(f'{BASE}/releases?limit=100') + existing = [release for release in releases if release['tag_name'] == tag] + if existing: + release = existing[0] + if not release['draft']: + raise ValueError('Release already published; choose a new version') + else: + release = request(f'{BASE}/releases', {'tag_name': tag, 'target_commitish': sha, 'name': f'Cutdex {version}', 'draft': True, 'body': f'Windows x64 portable ZIP and Android ARM64/x86_64 APK. Android currently uses the project debug signing key. Processing workers and models are distributed separately. Verified CI run: {run["id"]}.'}, 'POST') + assets = request(f"{BASE}/releases/{release['id']}/assets") + for name, body in contents.items(): + if '/' in name or '\\' in name: + raise ValueError('Unexpected artifact path') + prior = [asset for asset in assets if asset['name'] == name] + if prior: + downloaded = download(prior[0]) + if downloaded != body: + raise ValueError(f'Refusing to replace Release asset: {name}') + continue + boundary = uuid.uuid4().hex + payload = (f'--{boundary}\r\nContent-Disposition: form-data; name="attachment"; filename="{name}"\r\nContent-Type: application/octet-stream\r\n\r\n'.encode() + body + f'\r\n--{boundary}--\r\n'.encode()) + asset = request(f"{BASE}/releases/{release['id']}/assets?name={urllib.parse.quote(name)}", payload, 'POST', f'multipart/form-data; boundary={boundary}') + if download(asset) != body: + raise ValueError(f'Remote checksum verification failed: {name}') + request(f"{BASE}/releases/{release['id']}", {'draft': False}, 'PATCH') + print(f'{SERVER}/{REPO}/releases/tag/{tag}') + + +if __name__ == '__main__': + main() -- 2.54.0 From d20ce064a5f52b91ec613877c5cc7689e247c758 Mon Sep 17 00:00:00 2001 From: lingjhf Date: Tue, 6 Oct 2026 03:10:10 +0800 Subject: [PATCH 02/11] Make file identity and loopback fixtures portable to Windows --- test/adaptive_workspace_test.dart | 3 ++- test/agent_attachment_composer_test.dart | 3 ++- test/features/media/background_removal_controller_test.dart | 2 +- test/media_panel_test.dart | 2 +- test/workspace/external_media_import_test.dart | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/test/adaptive_workspace_test.dart b/test/adaptive_workspace_test.dart index 0994161..2ea6232 100644 --- a/test/adaptive_workspace_test.dart +++ b/test/adaptive_workspace_test.dart @@ -1054,7 +1054,8 @@ class _FixtureProjects extends Projects { id: 'media', name: 'Photo', storage: AssetStorage.external, - location: 'file:///test/photo.png', + location: const ExternalMediaFile(path: '/test/photo.png').sourceUri + .toString(), metadata: {'kind': 'image'}, ), ], diff --git a/test/agent_attachment_composer_test.dart b/test/agent_attachment_composer_test.dart index a9dfe6f..f9bf28b 100644 --- a/test/agent_attachment_composer_test.dart +++ b/test/agent_attachment_composer_test.dart @@ -47,7 +47,8 @@ class _AttachmentProjects extends Projects { id: 'asset-1', name: '片段.mov', storage: AssetStorage.external, - location: Uri.file('/tmp/片段.mov').toString(), + location: const ExternalMediaFile(path: '/tmp/片段.mov').sourceUri + .toString(), metadata: const {'kind': 'file'}, ), ], diff --git a/test/features/media/background_removal_controller_test.dart b/test/features/media/background_removal_controller_test.dart index aa5edb8..441a505 100644 --- a/test/features/media/background_removal_controller_test.dart +++ b/test/features/media/background_removal_controller_test.dart @@ -41,7 +41,7 @@ void main() { artifacts: [ ProcessingResourceArtifact( path: 'model.onnx', - url: Uri.parse('http://localhost:${server.port}/model'), + url: Uri.parse('http://127.0.0.1:${server.port}/model'), sha256: sha256.convert(payload).toString(), bytes: payload.length, ), diff --git a/test/media_panel_test.dart b/test/media_panel_test.dart index 2d39bea..5b6e49e 100644 --- a/test/media_panel_test.dart +++ b/test/media_panel_test.dart @@ -793,7 +793,7 @@ class _Projects extends Projects { id: file.localPath!, name: file.localPath!.split('/').last, storage: AssetStorage.external, - location: Uri.file(file.localPath!).toString(), + location: file.sourceUri.toString(), metadata: {'kind': mediaKindForPath(file.localPath!)}, ), ]; diff --git a/test/workspace/external_media_import_test.dart b/test/workspace/external_media_import_test.dart index 5670a8a..5606b62 100644 --- a/test/workspace/external_media_import_test.dart +++ b/test/workspace/external_media_import_test.dart @@ -19,7 +19,7 @@ AssetDocument _asset(String id, String path) => AssetDocument( id: id, name: id, storage: AssetStorage.external, - location: Uri.file(path).toString(), + location: ExternalMediaFile(path: path).sourceUri.toString(), ); class _Projects extends Projects { -- 2.54.0 From 2fb675e64c66e03b1dcfa2330c17251bf52c6b49 Mon Sep 17 00:00:00 2001 From: lingjhf Date: Tue, 6 Oct 2026 03:11:15 +0800 Subject: [PATCH 03/11] Audit portable Windows DLL dependencies before releasing --- .gitea/workflows/ci.yml | 1 + .gitea/workflows/release.yml | 1 + tool/gitea/package-app.py | 8 ++++++++ tool/windows/check_windows_release.py | 5 +++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 0c30f92..7f0520a 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -40,6 +40,7 @@ jobs: - run: flutter test --reporter expanded - run: flutter build apk --release --flavor production --target-platform android-arm64,android-x64 - run: flutter build windows --release --flavor production + - run: python -m pip install pefile==2024.8.26 - name: Package application run: python tool/gitea/package-app.py - name: Upload Android and Windows packages diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index f9fc108..c8d9377 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -9,6 +9,7 @@ on: required: true permissions: contents: write + actions: read concurrency: group: cutdex-release cancel-in-progress: false diff --git a/tool/gitea/package-app.py b/tool/gitea/package-app.py index b1459b2..99bcd13 100644 --- a/tool/gitea/package-app.py +++ b/tool/gitea/package-app.py @@ -4,6 +4,7 @@ import json from pathlib import Path import re import shutil +import sys import zipfile ROOT = Path(__file__).resolve().parents[2] @@ -25,6 +26,13 @@ def main(): if any(name.startswith('lib/armeabi-v7a/') for name in names): raise ValueError('APK must use supported 64-bit ABIs only') shutil.copyfile(apk, output / f'cutdex-{version}-android.apk') + sys.path.insert(0, str(ROOT / 'tool/windows')) + from check_windows_release import audit + unused_jni = windows / 'dartjni.dll' + if unused_jni.exists(): + unused_jni.unlink() + report = audit(windows, require_processing=False) + (output / 'windows-dependency-audit.json').write_text(json.dumps(report, indent=2) + '\n') package = output / f'cutdex-{version}-windows-x64.zip' with zipfile.ZipFile(package, 'w', compression=zipfile.ZIP_DEFLATED) as archive: for path in sorted(windows.rglob('*')): diff --git a/tool/windows/check_windows_release.py b/tool/windows/check_windows_release.py index 491c2ef..f53c01a 100644 --- a/tool/windows/check_windows_release.py +++ b/tool/windows/check_windows_release.py @@ -48,9 +48,10 @@ def pe_imports(path): for item in getattr(pe, attribute, [])}) -def audit(root, read_imports=pe_imports): +def audit(root, read_imports=pe_imports, *, require_processing=True): root = Path(root).resolve() - missing = [name for name in REQUIRED if not (root / name).is_file()] + required = REQUIRED if require_processing else tuple(name for name in REQUIRED if not name.startswith('processing/')) + missing = [name for name in required if not (root / name).is_file()] if missing: raise ValueError(f'Missing release files: {missing}') if not (root / 'data/flutter_assets').is_dir(): -- 2.54.0 From d648033f03cf33af47a3774156207e39c7ec2d1c Mon Sep 17 00:00:00 2001 From: lingjhf Date: Tue, 6 Oct 2026 03:13:28 +0800 Subject: [PATCH 04/11] Match verified main workflows using Gitea run path metadata --- tool/gitea/promote-release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/gitea/promote-release.py b/tool/gitea/promote-release.py index 058c8ad..9abb486 100644 --- a/tool/gitea/promote-release.py +++ b/tool/gitea/promote-release.py @@ -43,7 +43,7 @@ def main(): if tag != f'v{version}': raise ValueError('Release tag must match pubspec version') runs = request(f'{BASE}/actions/runs?limit=100')['workflow_runs'] - matches = [run for run in runs if run['head_sha'] == sha and run['head_branch'] == 'main' and run['conclusion'] == 'success' and run['name'] == 'Gitea CI'] + matches = [run for run in runs if run['head_sha'] == sha and run['path'].endswith('@refs/heads/main') and run['conclusion'] == 'success' and Path(run['path'].split('@')[0]).name == 'ci.yml'] if not matches: raise ValueError('No successful main CI for this exact commit; run CI before releasing') run = max(matches, key=lambda item: item['id']) -- 2.54.0 From 1c9b702c5459444298a64586e4c2ec1ddacaa1cb Mon Sep 17 00:00:00 2001 From: lingjhf Date: Tue, 6 Oct 2026 03:19:09 +0800 Subject: [PATCH 05/11] Document release setup and limit Android memory for parallel CI --- .gitea/README.md | 26 ++++++++++++++++++++++++++ .gitea/workflows/ci.yml | 5 +++++ 2 files changed, 31 insertions(+) create mode 100644 .gitea/README.md diff --git a/.gitea/README.md b/.gitea/README.md new file mode 100644 index 0000000..bdd7ea1 --- /dev/null +++ b/.gitea/README.md @@ -0,0 +1,26 @@ +# Gitea Windows and Android builds + +The Windows x64 host runner needs Flutter 3.47.5, 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. + +PR/main CI analyzes and tests the app, builds both platforms, and uploads +cutdex-release-packages including SHA256SUMS and a release manifest. Protect main +with `Gitea CI / Gitea CI passed (pull_request)`. + +After main CI succeeds, create v at that exact commit. The Release +workflow downloads the existing CI artifact, requires both APK and Windows ZIP, +checks their digests, uploads to a draft Release, verifies remote bytes, then +publishes it. It refuses to overwrite a published Release. A manual dispatch with +the existing tag can retry an interrupted draft publication. 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. diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 7f0520a..17df5ff 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -38,6 +38,11 @@ jobs: - run: flutter pub get --enforce-lockfile - run: dart analyze --fatal-infos - run: flutter test --reporter expanded + - name: Bound Android build memory on the shared runner + 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 - run: flutter build windows --release --flavor production - run: python -m pip install pefile==2024.8.26 -- 2.54.0 From d4e188c19f1fcf3dea4453e87e099867896ad2c3 Mon Sep 17 00:00:00 2001 From: lingjhf Date: Tue, 6 Oct 2026 03:39:24 +0800 Subject: [PATCH 06/11] ci(gitea): include app workspace package tests --- .gitea/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 17df5ff..6b4d897 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: 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 + - run: flutter test --reporter expanded test packages/cutdex_ui/test packages/cutdex_native/test - name: Bound Android build memory on the shared runner run: | $file = 'android/gradle.properties' -- 2.54.0 From f6666ac30d9c5481fe5659ac600eb631e26976f1 Mon Sep 17 00:00:00 2001 From: lingjhf Date: Tue, 6 Oct 2026 04:05:19 +0800 Subject: [PATCH 07/11] Pin Gitea SDK with verified native Windows package --- pubspec.lock | 36 ++++++++++++++++++------------------ pubspec.yaml | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 26aeaad..c0f4d1c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -214,8 +214,8 @@ packages: dependency: transitive description: path: "packages/editor" - ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 - resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + ref: de676503a60fb276bc645da89d0b1e8369d2d434 + resolved-ref: de676503a60fb276bc645da89d0b1e8369d2d434 url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" @@ -223,8 +223,8 @@ packages: dependency: transitive description: path: "packages/mcp" - ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 - resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + ref: de676503a60fb276bc645da89d0b1e8369d2d434 + resolved-ref: de676503a60fb276bc645da89d0b1e8369d2d434 url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" @@ -232,8 +232,8 @@ packages: dependency: transitive description: path: "packages/preview" - ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 - resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + ref: de676503a60fb276bc645da89d0b1e8369d2d434 + resolved-ref: de676503a60fb276bc645da89d0b1e8369d2d434 url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" @@ -241,8 +241,8 @@ packages: dependency: transitive description: path: "packages/project" - ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 - resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + ref: de676503a60fb276bc645da89d0b1e8369d2d434 + resolved-ref: de676503a60fb276bc645da89d0b1e8369d2d434 url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" @@ -250,8 +250,8 @@ packages: dependency: transitive description: path: "packages/runtime" - ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 - resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + ref: de676503a60fb276bc645da89d0b1e8369d2d434 + resolved-ref: de676503a60fb276bc645da89d0b1e8369d2d434 url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.0.1" @@ -259,8 +259,8 @@ packages: dependency: "direct main" description: path: "." - ref: be8f891 - resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + ref: de676503a60fb276bc645da89d0b1e8369d2d434 + resolved-ref: de676503a60fb276bc645da89d0b1e8369d2d434 url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" @@ -268,8 +268,8 @@ packages: dependency: transitive description: path: "packages/timeline" - ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 - resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + ref: de676503a60fb276bc645da89d0b1e8369d2d434 + resolved-ref: de676503a60fb276bc645da89d0b1e8369d2d434 url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.2.0" @@ -277,8 +277,8 @@ packages: dependency: transitive description: path: "packages/timeline_ui" - ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 - resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + ref: de676503a60fb276bc645da89d0b1e8369d2d434 + resolved-ref: de676503a60fb276bc645da89d0b1e8369d2d434 url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" @@ -286,8 +286,8 @@ packages: dependency: transitive description: path: "packages/tools" - ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 - resolved-ref: be8f89197d44c29cf6dff7eddbc50c1049886d08 + ref: de676503a60fb276bc645da89d0b1e8369d2d434 + resolved-ref: de676503a60fb276bc645da89d0b1e8369d2d434 url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git" source: git version: "0.1.0" diff --git a/pubspec.yaml b/pubspec.yaml index 8cfe1b6..a8ac8e9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: cutdex_sdk: git: url: ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git - ref: be8f891 + ref: de676503a60fb276bc645da89d0b1e8369d2d434 cutdex_agent: git: url: https://github.com/cutdex-ai/cutdex_agent.git -- 2.54.0 From 3a8d9b76e8156ea60eadc3b003a167266bcaa498 Mon Sep 17 00:00:00 2001 From: lingjhf Date: Tue, 6 Oct 2026 04:31:10 +0800 Subject: [PATCH 08/11] ci(gitea): isolate Python packaging dependencies in a venv --- .gitea/workflows/ci.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 6b4d897..8b11709 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -45,9 +45,15 @@ jobs: [IO.File]::WriteAllText($file, $properties + "`norg.gradle.workers.max=4`n") - run: flutter build apk --release --flavor production --target-platform android-arm64,android-x64 - run: flutter build windows --release --flavor production - - run: python -m pip install pefile==2024.8.26 + - 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.' } - name: Package application - run: python tool/gitea/package-app.py + run: | + & ./.build/package-tools/Scripts/python.exe tool/gitea/package-app.py - name: Upload Android and Windows packages uses: https://github.com/actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with: -- 2.54.0 From d6d665312e7b3ffecf0968ab333d8f0154719965 Mon Sep 17 00:00:00 2001 From: lingjhf Date: Tue, 6 Oct 2026 04:59:51 +0800 Subject: [PATCH 09/11] ci(gitea): use pinned Windows release instead of inherited source overrides --- .gitea/workflows/ci.yml | 6 +++++- android/settings.gradle.kts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 8b11709..d1cb3eb 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -44,7 +44,11 @@ jobs: $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 - - run: flutter build windows --release --flavor production + - name: Build Windows from the pinned Gitea native release + run: | + Remove-Item Env:CUTDEX_WINDOWS_PATH, Env:CUTDEX_WINDOWS_PACKAGE_PATH -ErrorAction SilentlyContinue + flutter build windows --release --flavor production + if ($LASTEXITCODE -ne 0) { throw 'Windows build failed.' } - name: Prepare isolated packaging tools run: | python -m venv .build/package-tools diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts index cd302e3..b869807 100644 --- a/android/settings.gradle.kts +++ b/android/settings.gradle.kts @@ -25,7 +25,7 @@ plugins { include(":app") -// Native source development is opt-in; default resolution uses GitHub Packages. +// Native source development is opt-in; default resolution uses Gitea Maven packages. providers.gradleProperty("cutdex.android.path").orNull?.let { nativePath -> includeBuild(nativePath) { dependencySubstitution { -- 2.54.0 From 6eefec12ae927f9f2d602935f932b2b4ea092fcd Mon Sep 17 00:00:00 2001 From: lingjhf Date: Tue, 6 Oct 2026 05:04:12 +0800 Subject: [PATCH 10/11] ci(gitea): package Flutter production flavor Windows output --- tool/gitea/package-app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/gitea/package-app.py b/tool/gitea/package-app.py index 99bcd13..23cc6e9 100644 --- a/tool/gitea/package-app.py +++ b/tool/gitea/package-app.py @@ -15,7 +15,7 @@ def main(): output = ROOT / 'dist' output.mkdir(exist_ok=True) apk = ROOT / 'build/app/outputs/flutter-apk/app-production-release.apk' - windows = ROOT / 'build/windows/x64/runner/Release' + windows = ROOT / 'build/windows/x64/production/runner/Release' if not apk.is_file() or not (windows / 'cutdex.exe').is_file(): raise ValueError('Both production builds are required') with zipfile.ZipFile(apk) as archive: -- 2.54.0 From 5bc8ce874fb5a012fde1e44ac042d559f9e82ece Mon Sep 17 00:00:00 2001 From: lingjhf Date: Tue, 6 Oct 2026 05:09:40 +0800 Subject: [PATCH 11/11] Fix Windows desktop window manager linking for release builds --- windows/runner/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt index 7150a3b..b2663e4 100644 --- a/windows/runner/CMakeLists.txt +++ b/windows/runner/CMakeLists.txt @@ -58,7 +58,7 @@ target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") # Add dependency libraries and include directories. Add any application-specific # dependencies here. -target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app dwmapi) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") include("${CMAKE_CURRENT_SOURCE_DIR}/update_configuration.cmake") -- 2.54.0