Compare commits

...

2 Commits

Author SHA1 Message Date
Gitea Actions
63a752356f game_godot: TinMerezhi.exe v1.0.54 [skip ci] 2026-11-26 13:41:37 +00:00
JunioR
46ea914b84 CI: exe у LFS завантажується через внутрішню адресу (ci/lfs_upload.py), бо git-lfs ходить на публічну
All checks were successful
ci-image / image (push) Successful in 14s
build / build (push) Successful in 2m19s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017HrHZuvQKryAdo6yY4xecB
2026-11-26 13:37:11 +00:00
3 changed files with 38 additions and 6 deletions

View File

@@ -141,16 +141,14 @@ jobs:
R="http://x:$TOKEN@gitea:3000/${{ github.repository }}.git"
cp game_godot/TinMerezhi.exe /tmp/TinMerezhi.exe
git config user.name "Gitea Actions"; git config user.email "actions@localhost"
git lfs install --local
# LFS upload links point to the public ROOT_URL (Funnel), unreachable from the job: rewrite them to the internal address
# (github.server_url is already http://gitea:3000 here, so the public address is written out)
git config lfs.transfer.enablehrefrewrite true
git config url."http://gitea:3000/".insteadOf "https://serv.tail9357bc.ts.net/"
# LFS clean filter only: ci/lfs_upload.py uploads the exe over the internal address, push skips the git-lfs hook
git lfs install --local --skip-repo
git fetch -q "$R" main && git checkout -qf -B main FETCH_HEAD
cp /tmp/TinMerezhi.exe game_godot/TinMerezhi.exe
git add game_godot/TinMerezhi.exe
git show :game_godot/TinMerezhi.exe | head -c 200 | grep -q git-lfs || { echo "exe is not an LFS pointer, refusing to commit it into git"; exit 1; }
if git diff --cached --quiet; then echo "exe unchanged"; exit 0; fi
python3 ci/lfs_upload.py "$R" game_godot/TinMerezhi.exe
git commit -qm "game_godot: TinMerezhi.exe $TAG [skip ci]"
git push -q "$R" HEAD:main
git push -q --no-verify "$R" HEAD:main
echo "main: game_godot/TinMerezhi.exe = $TAG"

31
ci/lfs_upload.py Normal file
View File

@@ -0,0 +1,31 @@
"""Uploads one file to the Gitea LFS store over the internal address.
git-lfs in the job cannot do it: the server answers with links to the public ROOT_URL (Funnel), unreachable from the job.
Usage: python3 ci/lfs_upload.py http://x:TOKEN@gitea:3000/owner/repo.git FILE"""
import base64, hashlib, json, os, sys, urllib.parse, urllib.request
remote, path = sys.argv[1], sys.argv[2]
u = urllib.parse.urlsplit(remote)
base = f"{u.scheme}://{u.hostname}" + (f":{u.port}" if u.port else "")
auth = "Basic " + base64.b64encode(f"{u.username}:{u.password}".encode()).decode()
data = open(path, "rb").read()
oid, size = hashlib.sha256(data).hexdigest(), len(data)
T = "application/vnd.git-lfs+json"
def call(url, body, headers, method="POST", ctype=T):
# keep only the path of the server's link and send it to the internal address
p = urllib.parse.urlsplit(url)
req = urllib.request.Request(base + p.path + (f"?{p.query}" if p.query else ""), data=body, method=method,
headers={**headers, "Content-Type": ctype, "Accept": T})
with urllib.request.urlopen(req) as r:
return r.read()
batch = json.dumps({"operation": "upload", "transfers": ["basic"], "objects": [{"oid": oid, "size": size}]}).encode()
obj = json.loads(call(f"{base}{u.path}/info/lfs/objects/batch", batch, {"Authorization": auth}))["objects"][0]
if "error" in obj:
sys.exit(f"LFS batch error: {obj['error']}")
act = obj.get("actions") or {}
if "upload" in act:
call(act["upload"]["href"], data, act["upload"].get("header", {}), "PUT", "application/octet-stream")
if "verify" in act:
call(act["verify"]["href"], json.dumps({"oid": oid, "size": size}).encode(), act["verify"].get("header", {}))
print(f"LFS {oid[:12]} ({size} bytes): {'uploaded' if 'upload' in act else 'already on the server'}")

BIN
game_godot/TinMerezhi.exe (Stored with Git LFS) Normal file

Binary file not shown.