fix(ci): install dotnet without admin access and preserve public release links
Gitea CI / Check code and tests (pull_request) Successful in 6m21s
Gitea CI / Build Android APK (pull_request) Successful in 4m1s
Gitea CI / Build Windows x64 app (pull_request) Successful in 10m7s
Gitea CI / Assemble and validate CI artifacts (pull_request) Successful in 1m54s
Gitea CI / Gitea CI passed (pull_request) Successful in 2s
Gitea CI / Audit and package Windows x64 (pull_request) Successful in 1m58s

This commit is contained in:
lingjhf committed 2026-10-06 15:07:28 +08:00
1 parent 8e523f0e89
commit 44cb452350
4 files changed
+22 -3

No files matched your search

+11 -3
View File
@@ -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)
+2
View File
@@ -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')