Compare commits

...

2 Commits

Author SHA1 Message Date
Claude
54564c5764 CI: build.yml працює в образі tinmerezhi-ci, без завантаження Godot, Go, fontTools і butler щоразу
All checks were successful
build / build (push) Successful in 1m26s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017HrHZxjRNfPF6rNJTvBXnq
2026-11-25 14:54:27 +00:00
Claude
3e78f4ccef CI: власний Docker-образ tinmerezhi-ci (Godot, малий шаблон, fontTools, go-winres, butler) і workflow перезбірки шаблону на сервері
All checks were successful
build / build (push) Successful in 1m14s
ci-image / image (push) Successful in 3m53s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017HrHZxjRNfPF6rNJTvBXnq
2026-11-25 14:42:27 +00:00
7 changed files with 134 additions and 29 deletions

View File

@@ -12,21 +12,18 @@ env:
jobs:
build:
runs-on: ubuntu-latest
# local image with Godot, the small template, fontTools, go-winres and butler (ci/Dockerfile, workflow ci-image.yml);
# if a job says the image is missing: Actions -> ci-image -> Run workflow
container:
image: tinmerezhi-ci:4.7.2
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # all tags and history: release notes from commits since the previous tag
- name: Godot
run: |
curl -sSL --fail -o /tmp/godot.zip "https://github.com/godotengine/godot/releases/download/${GODOT_VER}-stable/Godot_v${GODOT_VER}-stable_linux.x86_64.zip"
unzip -q -o /tmp/godot.zip -d /tmp/godot
install /tmp/godot/Godot_v${GODOT_VER}-stable_linux.x86_64 /usr/local/bin/godot
godot --version
- name: Import
working-directory: source_godot
run: godot --headless --path . --import
run: godot --version && godot --headless --path . --import
- name: Tests
run: GODOT=godot sh source_godot/run_tests.sh
@@ -47,9 +44,12 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
working-directory: source_godot
run: |
# small template without 3D/physics (tools/build_template.sh), kept in the prerelease template-<ver>;
# if it is missing or its checksum differs, fall back to the official 109 MB one
if curl -sSL --fail -o tools/template.exe "http://gitea:3000/${{ github.repository }}/releases/download/template-${GODOT_VER}/TinMerezhi-template.exe" \
# small template without 3D/physics (tools/build_template.sh): from the CI image, else from the prerelease
# template-<ver>; if both are missing or their checksum differs, fall back to the official 109 MB one
cp /opt/tinmerezhi/template.exe tools/template.exe 2>/dev/null || true
if echo "$(cat tools/template.sha256) tools/template.exe" | sha256sum -c - 2>/dev/null; then
echo "small template from the CI image: $(stat -c %s tools/template.exe) bytes"
elif curl -sSL --fail -o tools/template.exe "http://gitea:3000/${{ github.repository }}/releases/download/template-${GODOT_VER}/TinMerezhi-template.exe" \
&& echo "$(cat tools/template.sha256) tools/template.exe" | sha256sum -c -; then
echo "small template: $(stat -c %s tools/template.exe) bytes"
else
@@ -57,20 +57,11 @@ jobs:
python3 tools/fetch_template.py
cp ~/.local/share/godot/export_templates/${GODOT_VER}.stable/windows_release_x86_64.exe tools/template.exe
fi
# emoji font: keep only the characters the game uses (10.6 MB -> ~0.2 MB); without fontTools the full font stays
python3 -c 'import fontTools' 2>/dev/null || python3 -m pip install -q --break-system-packages fonttools \
|| (apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq python3-fonttools >/dev/null) || true
if python3 -c 'import fontTools'; then
python3 tools/subset_emoji.py fonts/NotoColorEmoji.ttf /tmp/emoji.ttf && mv /tmp/emoji.ttf fonts/NotoColorEmoji.ttf
godot --headless --path . --import
else
echo "::warning::fontTools not installed, emoji font not reduced"
fi
# emoji font: keep only the characters the game uses (10.6 MB -> ~0.2 MB), fontTools is in the CI image
python3 tools/subset_emoji.py fonts/NotoColorEmoji.ttf /tmp/emoji.ttf && mv /tmp/emoji.ttf fonts/NotoColorEmoji.ttf
godot --headless --path . --import
cp icon.ico tools/
# official Go toolchain from the Go module proxy, only to build go-winres (puts the icon into the exe)
curl -sSL --fail -o /tmp/go.zip "https://proxy.golang.org/golang.org/toolchain/@v/v0.0.1-go1.24.7.linux-amd64.zip"
unzip -q -o /tmp/go.zip -d /tmp/go
GOBIN=/usr/local/bin /tmp/go/golang.org/toolchain@v0.0.1-go1.24.7.linux-amd64/bin/go install github.com/tc-hib/go-winres@v0.3.3
# go-winres (from the CI image) puts the icon into the exe
(cd tools && go-winres patch --in winres.json --no-backup template.exe)
sed -i "s|^custom_template/release=.*|custom_template/release=\"$PWD/tools/template.exe\"|" export_presets.cfg
# version for the in-game updater: tag v1.0.4 -> 1.0.4
@@ -107,6 +98,4 @@ jobs:
TAG: ${{ github.ref_name }}
run: |
if [ -z "$BUTLER_API_KEY" ] || [ -z "$ITCH_TARGET" ]; then echo "itch.io: no BUTLER_API_KEY / ITCH_TARGET, skipped"; exit 0; fi
curl -sSL --fail -o /tmp/butler.zip https://broth.itch.zone/butler/linux-amd64/15.32.0/archive/default
unzip -q -o /tmp/butler.zip -d /tmp/butler && chmod +x /tmp/butler/butler
/tmp/butler/butler push game_godot "$ITCH_TARGET:windows" --userversion "${TAG#v}"
butler push game_godot "$ITCH_TARGET:windows" --userversion "${TAG#v}"

View File

@@ -0,0 +1,15 @@
# Rebuilds the local CI image tinmerezhi-ci:4.7.2 that build.yml runs in.
# Runs by hand (Actions -> ci-image -> Run workflow) or when the image recipe or the template checksum changes.
name: ci-image
on:
push:
branches: [main]
paths: ['ci/**', 'source_godot/tools/template.sha256', '.gitea/workflows/ci-image.yml']
workflow_dispatch:
jobs:
image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sh ci/build_image.sh

View File

@@ -0,0 +1,61 @@
# Rebuilds the small Windows export template (tools/template_custom.py) from Godot sources on the server,
# replaces TinMerezhi-template.exe in the prerelease template-<ver>, commits the new tools/template.sha256
# and rebuilds the CI image. ~20-40 min on 8 cores, up to ~8 GB RAM (lto=full), ~6 GB disk while it runs.
name: template
on:
push:
branches: [main]
paths: ['source_godot/tools/template_custom.py', 'source_godot/tools/build_template.sh']
workflow_dispatch:
env:
GODOT_VER: "4.7.2"
jobs:
template:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Toolchain (scons, mingw-w64 with posix threads)
run: |
apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends scons mingw-w64 >/dev/null
update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
x86_64-w64-mingw32-gcc --version | head -1; scons --version | tail -1
- name: Build template
working-directory: /tmp
run: |
time sh "$GITHUB_WORKSPACE/source_godot/tools/build_template.sh"
ls -l godot-$GODOT_VER-stable/bin/godot.windows.template_release.x86_64.exe
- name: Upload to the prerelease, commit the checksum
env:
TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
API: http://gitea:3000/api/v1/repos/${{ github.repository }}
run: |
EXE=/tmp/godot-$GODOT_VER-stable/bin/godot.windows.template_release.x86_64.exe
TAG=template-$GODOT_VER
H="Authorization: token $TOKEN"
getid() { python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])'; }
ID=$(curl -sf -H "$H" "$API/releases/tags/$TAG" | getid) || \
ID=$(curl -sf -H "$H" -H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"prerelease\":true,\"body\":\"Small Windows export template (tools/template_custom.py)\"}" "$API/releases" | getid)
# replace the old asset
for a in $(curl -sf -H "$H" "$API/releases/$ID/assets" | python3 -c 'import json,sys; [print(a["id"]) for a in json.load(sys.stdin) if a["name"]=="TinMerezhi-template.exe"]'); do
curl -sSf -X DELETE -H "$H" "$API/releases/$ID/assets/$a"
done
curl -sSf -H "$H" -F "attachment=@$EXE" "$API/releases/$ID/assets?name=TinMerezhi-template.exe" >/dev/null
sha256sum "$EXE" | cut -d' ' -f1 > source_godot/tools/template.sha256
echo "template: $(stat -c %s "$EXE") bytes, sha256 $(cat source_godot/tools/template.sha256)"
git config user.name "Gitea Actions"; git config user.email "actions@localhost"
if ! git diff --quiet source_godot/tools/template.sha256; then
git commit -qm "template.sha256: rebuilt template-$GODOT_VER" source_godot/tools/template.sha256
git pull -q --rebase "http://x:$TOKEN@gitea:3000/${{ github.repository }}.git" main
git push -q "http://x:$TOKEN@gitea:3000/${{ github.repository }}.git" HEAD:main
fi
- name: Rebuild the CI image with the new template
run: sh ci/build_image.sh

1
.gitignore vendored
View File

@@ -18,3 +18,4 @@ cleanup/
# Windows junk
Thumbs.db
desktop.ini
ci/template.exe

18
ci/Dockerfile Normal file
View File

@@ -0,0 +1,18 @@
# CI image for build.yml: Godot headless, the small Windows template, fontTools, go-winres, butler.
# Built on the server by ci/build_image.sh (workflow ci-image.yml) as the local image tinmerezhi-ci:4.7.2.
FROM node:20-bookworm
ARG GODOT_VER=4.7.2
RUN apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends python3-fonttools \
&& rm -rf /var/lib/apt/lists/*
RUN curl -sSL --fail -o /tmp/g.zip "https://github.com/godotengine/godot/releases/download/${GODOT_VER}-stable/Godot_v${GODOT_VER}-stable_linux.x86_64.zip" \
&& unzip -q /tmp/g.zip -d /tmp/g && install /tmp/g/Godot_v${GODOT_VER}-stable_linux.x86_64 /usr/local/bin/godot && rm -rf /tmp/g /tmp/g.zip
# go-winres puts the icon into the exe; the Go toolchain is only needed to build it
RUN curl -sSL --fail -o /tmp/go.zip "https://proxy.golang.org/golang.org/toolchain/@v/v0.0.1-go1.24.7.linux-amd64.zip" \
&& unzip -q /tmp/go.zip -d /tmp/go \
&& GOBIN=/usr/local/bin GOPATH=/tmp/gopath GOCACHE=/tmp/gocache /tmp/go/golang.org/toolchain@v0.0.1-go1.24.7.linux-amd64/bin/go install github.com/tc-hib/go-winres@v0.3.3 \
&& rm -rf /tmp/go /tmp/go.zip /tmp/gopath /tmp/gocache
RUN curl -sSL --fail -o /tmp/b.zip https://broth.itch.zone/butler/linux-amd64/15.32.0/archive/default \
&& unzip -q /tmp/b.zip -d /opt/butler && chmod +x /opt/butler/butler && ln -s /opt/butler/butler /usr/local/bin/butler && rm /tmp/b.zip
# the small template from the prerelease template-<ver> (build_image.sh downloads it next to this file)
COPY template.exe /opt/tinmerezhi/template.exe
RUN godot --version && go-winres --help >/dev/null && butler -V && python3 -c 'import fontTools'

16
ci/build_image.sh Normal file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
# Builds the local CI image tinmerezhi-ci:<ver> through the host Docker (the runner mounts /var/run/docker.sock into jobs).
# Run from the repo root inside a Gitea Actions job (needs http://gitea:3000).
set -e
VER="${GODOT_VER:-4.7.2}"
REPO="${GITHUB_REPOSITORY:-junior/TinMerezhi}"
if ! command -v docker >/dev/null; then
curl -sSL --fail -o /tmp/docker.tgz https://download.docker.com/linux/static/stable/x86_64/docker-27.5.1.tgz
tar xzf /tmp/docker.tgz -C /tmp && install /tmp/docker/docker /usr/local/bin/docker
fi
curl -sSL --fail -o ci/template.exe "http://gitea:3000/$REPO/releases/download/template-$VER/TinMerezhi-template.exe"
echo "$(cat source_godot/tools/template.sha256) ci/template.exe" | sha256sum -c -
docker build --pull=false --build-arg GODOT_VER="$VER" -t "tinmerezhi-ci:$VER" ci
rm -f ci/template.exe
docker image prune -f >/dev/null # drop the previous untagged image
docker images tinmerezhi-ci

View File

@@ -69,8 +69,10 @@
**Малий exe (~35 МБ замість ~120 МБ).** CI бере власний шаблон без 3D, фізики, навігації, XR і зайвих модулів
(`tools/template_custom.py`) з пререлізу `template-4.7.2` у Gitea і звіряє `tools/template.sha256`; шрифт емодзі
урізається до символів, що є в коді (`tools/subset_emoji.py`, потрібен `pip install fonttools`). Новий шаблон
(інша версія Godot або інші модулі): `tools/build_template.sh` (~20–40 хв, mingw-w64 + scons), викласти exe в
пререліз `template-<версія>` як `TinMerezhi-template.exe` і оновити `tools/template.sha256`. Пререліз не бачить
(інша версія Godot або інші модулі) збирає на сервері workflow `template.yml`: сам, коли змінюється
`tools/template_custom.py`, або вручну (Actions → template → Run workflow). Він кладе exe в пререліз
`template-<версія>` як `TinMerezhi-template.exe`, комітить новий `tools/template.sha256` і перезбирає CI-образ
(~20–40 хв, до ~8 ГБ RAM, ~6 ГБ диска). Пререліз не бачить
автооновлення гри (`/releases/latest` віддає лише звичайні релізи). Нові класи рушія в коді: перевір, що їх не вимкнено.
## Реліз
@@ -78,4 +80,7 @@
Кожен push у `main` — тести й бот балансу в Gitea Actions (`.gitea/workflows/build.yml`).
Тег `v*` (`git tag v1.0.17 && git push origin v1.0.17`) — ще й збірка `TinMerezhi.exe` у Releases
з нотатками зі списку комітів після попереднього тегу, і публікація на itch.io через butler.
Збірка йде в локальному Docker-образі `tinmerezhi-ci:4.7.2` (`ci/Dockerfile`: Godot, малий шаблон, fontTools,
go-winres, butler), тож нічого не завантажується щоразу. Образ перезбирає workflow `ci-image.yml`
(сам при зміні `ci/` або `tools/template.sha256`, або вручну); якщо збірка каже, що образу немає, запусти його.
Гра бачить новий реліз сама (`updater.gd`).