a6a13003c2
The mod (airdef-mod/), its generated models and sounds, the fork's patches over upstream Horizon (horizon-patches/, HORIZON_COMMIT), a cross-platform build/install/run script (tools/airdef.py), CI that builds and releases on every push (.gitea/workflows/build.yml) and a setup guide (docs/INSTALL.md). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
166 lines
6.2 KiB
YAML
166 lines
6.2 KiB
YAML
# Сборка на каждый пуш: мод (.hmod, для всех ОС) и игра-форк для Linux;
|
|
# для Windows и macOS — если в репозитории заданы переменные BUILD_WINDOWS / BUILD_MACOS = true
|
|
# и подключены раннеры с метками windows-latest / macos-latest.
|
|
# Пуш в main публикует релиз build-<номер> со всеми собранными архивами.
|
|
name: build
|
|
|
|
on:
|
|
push:
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: never
|
|
|
|
jobs:
|
|
mod:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Rust
|
|
run: |
|
|
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --target wasm32-unknown-unknown
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
- name: Форк Horizon (исходники)
|
|
run: python3 tools/airdef.py fork
|
|
- name: Мод
|
|
run: python3 tools/airdef.py mod
|
|
- name: Архив
|
|
run: |
|
|
mkdir -p out
|
|
cp airdef-mod/target/horizon-mod/airdef.hmod out/airdef.hmod
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: airdef-hmod
|
|
path: out/airdef.hmod
|
|
|
|
game-linux:
|
|
runs-on: ubuntu-latest
|
|
needs: mod
|
|
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: Rust
|
|
run: |
|
|
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
horizon/target
|
|
key: game-linux-${{ hashFiles('HORIZON_COMMIT', 'horizon-patches/*') }}
|
|
restore-keys: game-linux-
|
|
- name: Форк Horizon
|
|
run: python3 tools/airdef.py fork
|
|
- name: Игра
|
|
run: python3 tools/airdef.py game
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: airdef-hmod
|
|
path: out
|
|
- name: Архив
|
|
run: |
|
|
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 "$D/"
|
|
cp docs/INSTALL.md "$D/"
|
|
tar czf "out/$D.tar.gz" "$D"
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: airdef-linux
|
|
path: out/airdef-linux-x86_64.tar.gz
|
|
|
|
game-macos:
|
|
if: vars.BUILD_MACOS == 'true'
|
|
runs-on: macos-latest
|
|
needs: mod
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Rust
|
|
run: |
|
|
command -v cargo || curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
- name: Форк Horizon
|
|
run: python3 tools/airdef.py fork
|
|
- name: Игра
|
|
run: python3 tools/airdef.py game
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: airdef-hmod
|
|
path: out
|
|
- name: Архив
|
|
run: |
|
|
D=airdef-macos-arm64
|
|
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"
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: airdef-macos
|
|
path: out/airdef-macos-arm64.tar.gz
|
|
|
|
game-windows:
|
|
if: vars.BUILD_WINDOWS == 'true'
|
|
runs-on: windows-latest
|
|
needs: mod
|
|
defaults:
|
|
run:
|
|
shell: pwsh
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Rust
|
|
run: |
|
|
if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) {
|
|
Invoke-WebRequest https://win.rustup.rs/x86_64 -OutFile rustup-init.exe
|
|
.\rustup-init.exe -y --profile minimal
|
|
}
|
|
"$env:USERPROFILE\.cargo\bin" | Out-File -Append -Encoding utf8 $env:GITHUB_PATH
|
|
- name: Форк Horizon
|
|
run: python tools/airdef.py fork
|
|
- name: Игра
|
|
run: python tools/airdef.py game
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: airdef-hmod
|
|
path: out
|
|
- name: Архив
|
|
run: |
|
|
$D = "airdef-windows-x86_64"
|
|
New-Item -ItemType Directory -Force $D | Out-Null
|
|
Copy-Item horizon\target\fast\horizon-client.exe, horizon\target\fast\horizon-ctl.exe, out\airdef.hmod, dist\play.bat, docs\INSTALL.md $D
|
|
Compress-Archive -Path $D -DestinationPath "out\$D.zip" -Force
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: airdef-windows
|
|
path: out/airdef-windows-x86_64.zip
|
|
|
|
release:
|
|
if: github.ref == 'refs/heads/main' && !failure() && !cancelled()
|
|
runs-on: ubuntu-latest
|
|
needs: [mod, game-linux, game-macos, game-windows]
|
|
steps:
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
- name: Релиз
|
|
env:
|
|
TOKEN: ${{ secrets.RELEASE_TOKEN || gitea.token }}
|
|
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
|
TAG: build-${{ github.run_number }}
|
|
SHA: ${{ github.sha }}
|
|
run: |
|
|
set -e
|
|
BODY=$(printf 'Сборка %s (%s).\n\n- airdef.hmod — мод, для всех ОС;\n- airdef-<ОС>.* — игра-форк Horizon с модом и скриптом запуска.\n\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"]}))')
|
|
ID=$(curl -sf -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" "$API/releases" -d "$DATA" | python3 -c 'import json,sys;print(json.load(sys.stdin)["id"])')
|
|
find artifacts -type f | while read -r f; 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
|