CI: only the mod on push (1 job, low priority); the game on demand, refused when the disk is low
build / mod (push) Successful in 5m9s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-29 12:01:08 +03:00
parent 2b5ad8d888
commit 1ba57ee465
14 changed files with 190 additions and 63 deletions
+15 -44
View File
@@ -1,6 +1,7 @@
# Сборка на каждый пуш: мод (.hmod, для всех ОС) и игра-форк для Linux, в одной задаче
# (без передачи артефактов между задачами). Пуш в main публикует релиз build-<номер>.
# Сборки для Windows и macOS — desktop.yml (вручную).
# На каждый пуш: только мод (.hmod, один для всех ОС) и релиз build-<номер> с ним.
# Раннер живёт на одной машине с Gitea и другими сервисами (2 ядра, 4 ГБ): сборка мода лёгкая —
# один поток компиляции, низший приоритет, без системных пакетов и без кэша target.
# Игра-форк собирается отдельно и только вручную: game.yml (Linux) и desktop.yml (macOS/Windows).
name: build
on:
@@ -9,55 +10,28 @@ on:
env:
CARGO_TERM_COLOR: never
# The runner shares its machine with Gitea: two compile jobs at a time, no incremental
# files, so the build doesn't starve the server (Gitea answered 500 under a full build).
CARGO_BUILD_JOBS: "2"
CARGO_BUILD_JOBS: "1"
CARGO_INCREMENTAL: "0"
# Lowest CPU priority for the long steps (ionice too where the image has it, below).
LOW: nice -n 19
jobs:
build:
mod:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Системные библиотеки
run: |
SUDO=$(command -v sudo || true)
$SUDO apt-get update -qq
$SUDO apt-get install -y -qq build-essential pkg-config libasound2-dev libudev-dev
- name: Низкий приоритет
run: command -v ionice >/dev/null && echo "LOW=nice -n 19 ionice -c 3" >> "$GITHUB_ENV" || true
- name: Rust
run: |
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --target wasm32-unknown-unknown
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
# Only the small things are cached: the build's target folder is gigabytes, and moving it
# through the cache server timed out and loaded the machine.
# Инструмент упаковки (cargo-horizon-mod без пробного запуска) — единственное, что стоит кэшировать.
- uses: actions/cache@v3
continue-on-error: true
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: cargo-${{ hashFiles('HORIZON_COMMIT') }}
restore-keys: cargo-
path: ~/.cargo/bin/cargo-horizon-mod
key: tool-${{ hashFiles('HORIZON_COMMIT', 'horizon-patches/*') }}
- name: Форк Horizon
run: $LOW python3 tools/airdef.py fork
run: nice -n 19 python3 tools/airdef.py fork
- name: Мод
run: $LOW python3 tools/airdef.py mod
- name: Игра
run: $LOW python3 tools/airdef.py game
- name: Архивы
run: |
mkdir -p out
cp airdef-mod/target/horizon-mod/airdef.hmod out/airdef.hmod
D=airdef-linux-x86_64
mkdir -p "$D"
cp horizon/target/fast/horizon-client horizon/target/fast/horizon-ctl out/airdef.hmod dist/play.sh docs/INSTALL.md "$D/"
tar czf "out/$D.tar.gz" "$D"
ls -la out
run: nice -n 19 python3 tools/airdef.py mod
- name: Релиз
if: github.ref == 'refs/heads/main'
env:
@@ -67,17 +41,14 @@ jobs:
SHA: ${{ github.sha }}
run: |
set -e
BODY=$(printf 'Сборка %s (%s).\n\n- airdef.hmod — мод, для всех ОС;\n- airdef-linux-x86_64.tar.gz — игра-форк Horizon для Linux с модом и play.sh.\n\nСборки для Windows и macOS добавляет workflow desktop (запуск вручную с этим тегом).\nКак запускать: docs/INSTALL.md.' "$TAG" "$SHA")
mkdir -p out && cp airdef-mod/target/horizon-mod/airdef.hmod out/airdef.hmod
BODY=$(printf 'Сборка %s (%s).\n\n- airdef.hmod — мод, для всех ОС.\n\nИгра-форк Horizon (нужна для мода): собрать у себя — python3 tools/airdef.py all, или запустить вручную workflow game (Linux) / desktop (macOS, Windows) с этим тегом.\nКак запускать: docs/INSTALL.md.' "$TAG" "$SHA")
DATA=$(BODY="$BODY" python3 -c 'import json,os;print(json.dumps({"tag_name":os.environ["TAG"],"target_commitish":os.environ["SHA"],"name":os.environ["TAG"],"body":os.environ["BODY"]}))')
if [ -z "$TOKEN" ]; then echo "::error::нет токена: добавь секрет RELEASE_TOKEN"; exit 1; fi
CODE=$(curl -sS -o release.json -w '%{http_code}' -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" "$API/releases" -d "$DATA")
if [ "$CODE" != "201" ]; then
echo "::error::Gitea не создала релиз (HTTP $CODE): $(cat release.json). Встроенному токену может не хватать прав — добавь секрет RELEASE_TOKEN (токен с правом записи в репозиторий)."
echo "::error::Gitea не создала релиз (HTTP $CODE): $(cat release.json). Проверь секрет RELEASE_TOKEN (токен с правом записи в репозиторий)."
exit 1
fi
ID=$(python3 -c 'import json;print(json.load(open("release.json"))["id"])')
for f in out/*; do
name=$(basename "$f")
echo "upload $name"
curl -sf -X POST -H "Authorization: token $TOKEN" -F "attachment=@$f" "$API/releases/$ID/assets?name=$name" > /dev/null
done
curl -sf -X POST -H "Authorization: token $TOKEN" -F "attachment=@out/airdef.hmod" "$API/releases/$ID/assets?name=airdef.hmod" > /dev/null