From 44cb452350d6e581b75ecd582d7f6d3f8754f686 Mon Sep 17 00:00:00 2001 From: lingjhf Date: Tue, 6 Oct 2026 15:07:28 +0800 Subject: [PATCH] fix(ci): install dotnet without admin access and preserve public release links --- .gitea/CI_PERFORMANCE.md | 3 +++ .gitea/workflows/ci.yml | 6 ++++++ tool/gitea/release_transport.py | 14 +++++++++++--- tool/gitea/test_transfer_tools.py | 2 ++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.gitea/CI_PERFORMANCE.md b/.gitea/CI_PERFORMANCE.md index e77a192..7a98aed 100644 --- a/.gitea/CI_PERFORMANCE.md +++ b/.gitea/CI_PERFORMANCE.md @@ -28,6 +28,9 @@ the runner user's `%LOCALAPPDATA%/Cutdex/ci-tools/`. Later builds reuse them aft version checks. Python interpreter identity and tool versions isolate the cache, and a mutex protects installation across concurrent workflows. .NET setup remains in the Windows packaging job to provide SDK 10 and the runtime required by `vpk`. +The .NET installation uses the runner user's `Cutdex/ci-tools/dotnet` directory +through `DOTNET_INSTALL_DIR` and `DOTNET_ROOT`, so setup needs no administrator +access and later jobs reuse the installed SDK and runtime. The Windows build verifies that the resolved deskup native SDK matches the pinned Velopack version before saving the app. Packaging imports no Flutter package configuration and independently verifies the installed vpk version. diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index d958953..1839eb9 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -148,6 +148,12 @@ jobs: with: name: cutdex-windows-app path: build/windows/x64/production/runner/Release/ + - name: Configure user .NET installation + run: | + $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: diff --git a/tool/gitea/release_transport.py b/tool/gitea/release_transport.py index d9e0f2b..7384f0d 100644 --- a/tool/gitea/release_transport.py +++ b/tool/gitea/release_transport.py @@ -53,12 +53,16 @@ def retry_read(operation): def request(url, data=None, method=None, content_type='application/json'): + endpoint = transport_url(url) headers = {'Authorization': 'token ' + os.environ['GITEA_TOKEN']} + if endpoint != url: + # Gitea constructs response links from Host, even when reached locally. + headers['Host'] = 'git.orangraph.com' if data is not None: headers['Content-Type'] = content_type if isinstance(data, dict): data = json.dumps(data).encode() - req = urllib.request.Request(transport_url(url), data=data, headers=headers, method=method) + req = urllib.request.Request(endpoint, data=data, headers=headers, method=method) with urllib.request.urlopen(req, timeout=300) as response: body = response.read() return json.loads(body) if body and 'application/json' in response.headers.get('Content-Type', '') else body @@ -74,8 +78,12 @@ def attachment_url(asset): def fingerprint(asset): """Hash one remote attachment in chunks, keeping memory usage bounded.""" sha256, sha1, size = hashlib.sha256(), hashlib.sha1(), 0 - req = urllib.request.Request(transport_url(attachment_url(asset)), - headers={'Authorization': 'token ' + os.environ['GITEA_TOKEN']}) + url = attachment_url(asset) + endpoint = transport_url(url) + headers = {'Authorization': 'token ' + os.environ['GITEA_TOKEN']} + if endpoint != url: + headers['Host'] = 'git.orangraph.com' + req = urllib.request.Request(endpoint, headers=headers) with urllib.request.urlopen(req, timeout=300) as response: while chunk := response.read(1024 * 1024): sha256.update(chunk) diff --git a/tool/gitea/test_transfer_tools.py b/tool/gitea/test_transfer_tools.py index 2545d13..69f3d66 100644 --- a/tool/gitea/test_transfer_tools.py +++ b/tool/gitea/test_transfer_tools.py @@ -28,6 +28,7 @@ class TransferToolsTests(unittest.TestCase): self.assertEqual(request.full_url, 'http://127.0.0.1:3000/api/v1/releases?name=a%20b') self.assertEqual(request.get_method(), 'POST') self.assertEqual(request.get_header('Authorization'), 'token test-token') + self.assertEqual(request.get_header('Host'), 'git.orangraph.com') self.assertEqual(request.data, b'package') self.assertEqual(transfers.SERVER, 'https://git.orangraph.com') @@ -38,6 +39,7 @@ class TransferToolsTests(unittest.TestCase): patch.object(transfers.urllib.request, 'urlopen', return_value=io.BytesIO(b'app')) as open_url: result = transfers.fingerprint(asset) self.assertEqual(open_url.call_args.args[0].full_url, 'http://127.0.0.1:3000/attachments/example') + self.assertEqual(open_url.call_args.args[0].get_header('Host'), 'git.orangraph.com') self.assertEqual(result['sha256'], hashlib.sha256(b'app').hexdigest()) self.assertEqual(asset['browser_download_url'], 'https://git.orangraph.com/attachments/example')