Files
yugioh-legacy-engine/.gitea/workflows/release.yml
T
donnyandClaude Fable 5.1 2344e5dae1 tag partner cards: ygol_query_tag_cards + STOC_TAG_PARTNER_CARDS 0x5F, capability 0x2000, protocol 9 (TICKET-405)
Core: ygol_query_tag_cards(pduel, playerid, out) reads the waiting tag
partner's tag_list_hand / tag_list_extra (bit 31 = face-up, like
MSG_TAG_SWAP) and tag_list_main sorted ascending; returns the byte length,
0 when not a tag duel. Read only.

Server: STOC_TAG_PARTNER_CARDS 0x5F = u8 side + those bytes, no stamp, to
that side's two seats only (never the other team, never an observer):
after start_duel, after every MSG_TAG_SWAP, and in a seated duelist's
field resync. FEATURE_TAG_PARTNER_CARDS 0x2000 advertised by single_duel
and tag_duel; FEATURE_PROTOCOL 8 -> 9. 0x800 / 0x1000 stay reserved for
proposals 44 / 45.

Binding: StocMessage.TagPartnerCards, FeatureFlags.TagPartnerCards, the
TagPartnerCards record + StocCodecs.TagPartnerCards,
EngineApi.ygol_query_tag_cards, Capability.ProtocolVersion 9, tests.

Contract rows, CHANGELOG v1.2.0, the probe's tag partner cards room, the
export gates 334 / 855 / 849 -> 335 / 856 / 850.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-15 23:26:39 -07:00

232 lines
11 KiB
YAML

# Every push and pull request: the three builds and their gates (Windows on the self-hosted
# unity-windows runner, Linux + Android in Docker on ubuntu-latest). A v* tag adds the release:
# one Gitea release named after the tag with the per-platform bundles, engine.json and the
# CHANGELOG section for that version as the body. A gate failure in any build means no release.
#
# ygol-engine-win64.zip ygol-engine.dll, ygol-engine.pdb, engine.json
# ygol-engine-binding.zip YGOLegacy.Engine.dll, YGOLegacy.Engine.pdb (the C# binding, built and tested by dotnet)
# ygol-engine-linux-x64.tar.gz libygol-engine.so, engine.json
# ygoserver-linux-x64.tar.gz ygoserver, engine.json
# ygol-engine-android-arm64.tar.gz libygol-engine.so, engine.json
# engine.json the same content as in every bundle
#
# The Windows runner runs no JavaScript action (the Unity repo's pipeline never did): its build
# stays on the runner's disk and is attached by the last job; its engine.json travels as a job
# output. The token is the run's own GITHUB_TOKEN; the release is in this repo.
name: Release
on:
push:
branches: ['**']
tags: ['v*']
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: false
env:
CHECKOUT_DIR: C:\gitea-runner\checkout\yugioh-legacy-engine
OUT_DIR: C:\gitea-runner\release-out\ygol-engine
API: https://gitea.dev.blueoceanswim.com/api/v1/repos/donny/yugioh-legacy-engine
jobs:
windows:
runs-on: unity-windows
defaults:
run:
shell: powershell
outputs:
engine: ${{ steps.build.outputs.engine }}
steps:
- name: Sync checkout
run: |
$url = "https://gitea-actions:${{ secrets.GITHUB_TOKEN }}@gitea.dev.blueoceanswim.com/donny/yugioh-legacy-engine.git"
if (-not (Test-Path "$env:CHECKOUT_DIR\.git")) {
git clone $url $env:CHECKOUT_DIR
if ($LASTEXITCODE -ne 0) { git clone $url $env:CHECKOUT_DIR }
if ($LASTEXITCODE -ne 0) { exit 1 }
}
Set-Location $env:CHECKOUT_DIR
git remote set-url origin $url
git fetch --force --tags origin
if ($LASTEXITCODE -ne 0) { exit 1 }
git checkout --force $env:GITHUB_SHA
if ($LASTEXITCODE -ne 0) { exit 1 }
git clean -fdx -e out
if ($LASTEXITCODE -ne 0) { exit 1 }
- name: Build (contract check, export gate 335, engine.json)
id: build
run: |
$version = "local"
if ($env:GITHUB_REF -like "refs/tags/v*") { $version = $env:GITHUB_REF_NAME }
try { & "$env:CHECKOUT_DIR\build\windows.ps1" -Version $version }
catch { Write-Host "##[error]$_"; exit 1 }
$out = "$env:CHECKOUT_DIR\out\win64"
# the DLL must answer the tag
$got = python -c "import ctypes; l = ctypes.CDLL(r'$out\ygol-engine.dll'); l.ygol_engine_version.restype = ctypes.c_char_p; print(l.ygol_engine_version().decode())"
if ($LASTEXITCODE -ne 0) { exit 1 }
Write-Host "ygol_engine_version() = $got"
if ($got -ne $version) { Write-Host "##[error]ygol_engine_version() returned '$got', expected '$version'"; exit 1 }
$engine = (Get-Content "$out\engine.json" -Raw | ConvertFrom-Json | ConvertTo-Json -Compress)
"engine=$engine" | Out-File -Append -Encoding ascii $env:GITHUB_OUTPUT
# stage the bundle on the runner's disk for the attach job
$stage = "$env:OUT_DIR\$version"
if (Test-Path $stage) { Remove-Item $stage -Recurse -Force }
New-Item -ItemType Directory -Force -Path $stage | Out-Null
Copy-Item "$out\ygol-engine.dll", "$out\ygol-engine.pdb", "$out\engine.json" $stage
tar.exe -a -cf "$stage\ygol-engine-win64.zip" -C $stage ygol-engine.dll ygol-engine.pdb engine.json
if ($LASTEXITCODE -ne 0) { exit 1 }
Get-ChildItem $stage | Format-Table Name, Length
- name: Binding (dotnet build + test, ygol-engine-binding.zip)
run: |
$version = "local"
if ($env:GITHUB_REF -like "refs/tags/v*") { $version = $env:GITHUB_REF_NAME }
Set-Location $env:CHECKOUT_DIR
dotnet build binding\YGOLegacy.Engine -c Release -p:EngineVersion=$version
if ($LASTEXITCODE -ne 0) { exit 1 }
dotnet test binding\YGOLegacy.Engine.Tests -c Release -p:EngineVersion=$version
if ($LASTEXITCODE -ne 0) { exit 1 }
$bin = "$env:CHECKOUT_DIR\binding\YGOLegacy.Engine\bin\Release\netstandard2.1"
$got = (Get-Item "$bin\YGOLegacy.Engine.dll").VersionInfo.ProductVersion
Write-Host "YGOLegacy.Engine.dll ProductVersion = $got"
if ($got -ne $version) { Write-Host "##[error]YGOLegacy.Engine.dll is stamped '$got', expected '$version'"; exit 1 }
$stage = "$env:OUT_DIR\$version"
Copy-Item "$bin\YGOLegacy.Engine.dll", "$bin\YGOLegacy.Engine.pdb" $stage
tar.exe -a -cf "$stage\ygol-engine-binding.zip" -C $stage YGOLegacy.Engine.dll YGOLegacy.Engine.pdb
if ($LASTEXITCODE -ne 0) { exit 1 }
Get-ChildItem $stage | Format-Table Name, Length
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build (contract check, export gate 856, engine.json)
run: |
version=local
case "$GITHUB_REF" in refs/tags/v*) version="$GITHUB_REF_NAME";; esac
./build/linux.sh "$version"
cd out/linux-x64
tar czf ygol-engine-linux-x64.tar.gz libygol-engine.so engine.json
tar czf ygoserver-linux-x64.tar.gz ygoserver engine.json
ls -l
- uses: actions/upload-artifact@v3
with:
name: linux-x64
path: |
out/linux-x64/ygol-engine-linux-x64.tar.gz
out/linux-x64/ygoserver-linux-x64.tar.gz
out/linux-x64/engine.json
if-no-files-found: error
android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build (contract check, export gate 850, engine.json)
run: |
version=local
case "$GITHUB_REF" in refs/tags/v*) version="$GITHUB_REF_NAME";; esac
./build/android.sh "$version"
cd out/android-arm64
tar czf ygol-engine-android-arm64.tar.gz libygol-engine.so engine.json
ls -l
- uses: actions/upload-artifact@v3
with:
name: android-arm64
path: |
out/android-arm64/ygol-engine-android-arm64.tar.gz
out/android-arm64/engine.json
if-no-files-found: error
release:
needs: [windows, linux, android]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
outputs:
id: ${{ steps.create.outputs.id }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
path: dist
- name: engine.json agrees on every platform and names the tag
env:
WINDOWS_ENGINE: ${{ needs.windows.outputs.engine }}
run: |
set -eu
tag="$GITHUB_REF_NAME"
echo "$WINDOWS_ENGINE" | jq -c . > dist/engine-windows.json
for f in dist/engine-windows.json dist/linux-x64/engine.json dist/android-arm64/engine.json; do
v=$(jq -r .version "$f"); [ "$v" = "$tag" ] || { echo "::error::$f says version $v, tag is $tag"; exit 1; }
b=$(jq -r .binding "$f"); [ "$b" = "$tag" ] || { echo "::error::$f says binding $b, tag is $tag"; exit 1; }
done
# the export count is per platform; version, protocol, capabilities and binding must agree everywhere
for f in dist/engine-windows.json dist/linux-x64/engine.json dist/android-arm64/engine.json; do
jq -c '{version, protocol, capabilities, binding}' "$f"
done | sort -u | tee dist/agree.txt
[ "$(wc -l < dist/agree.txt)" -eq 1 ] || { echo "::error::the platforms disagree on version / protocol / capabilities / binding"; exit 1; }
cp dist/linux-x64/engine.json dist/engine.json
- name: The CHANGELOG section for this version is the release body
run: |
set -eu
tag="$GITHUB_REF_NAME"
awk -v tag="$tag" '
/^## / { on = ($2 == tag); next }
on { print }' CHANGELOG.md > dist/body.md
[ -s dist/body.md ] || { echo "::error::CHANGELOG.md has no '## $tag' section"; exit 1; }
cat dist/body.md
- name: Create the release (refused if it already exists) and attach the Linux and Android assets
id: create
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -eu
tag="$GITHUB_REF_NAME"
code=$(curl -s -o /dev/null -w '%{http_code}' -H "Authorization: token $TOKEN" "$API/releases/tags/$tag")
[ "$code" = "404" ] || { echo "::error::release $tag already exists (http $code); a bad release gets a new patch tag, never a re-upload"; exit 1; }
jq -n --arg tag "$tag" --rawfile body dist/body.md \
'{tag_name: $tag, target_commitish: env.GITHUB_SHA, name: $tag, body: $body, draft: false, prerelease: false}' > dist/release.json
curl -sS -f -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
--data-binary @dist/release.json "$API/releases" > dist/created.json
id=$(jq -r .id dist/created.json)
echo "release id $id"
echo "id=$id" >> "$GITHUB_OUTPUT"
for f in dist/linux-x64/ygol-engine-linux-x64.tar.gz dist/linux-x64/ygoserver-linux-x64.tar.gz \
dist/android-arm64/ygol-engine-android-arm64.tar.gz dist/engine.json; do
name=$(basename "$f")
echo "uploading $name"
curl -sS -f -o /dev/null -X POST -H "Authorization: token $TOKEN" -F "attachment=@$f" "$API/releases/$id/assets?name=$name"
done
echo "https://gitea.dev.blueoceanswim.com/donny/yugioh-legacy-engine/releases/tag/$tag"
attach-windows:
needs: [windows, release]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: unity-windows
defaults:
run:
shell: powershell
steps:
- name: Attach ygol-engine-win64.zip and ygol-engine-binding.zip
run: |
$tag = $env:GITHUB_REF_NAME
$id = "${{ needs.release.outputs.id }}"
$respFile = Join-Path $env:TEMP "ygol-engine-upload.txt"
foreach ($name in @("ygol-engine-win64.zip", "ygol-engine-binding.zip")) {
$zip = "$env:OUT_DIR\$tag\$name"
if (-not (Test-Path $zip)) { Write-Host "##[error]$zip is missing"; exit 1 }
$status = & curl.exe -s -o $respFile -w "%{http_code}" -X POST `
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -F "attachment=@$zip" `
"$env:API/releases/$id/assets?name=$name"
if ($LASTEXITCODE -ne 0 -or [int]$status -ge 400) {
Write-Host "curl exit=$LASTEXITCODE http=$status"
if (Test-Path $respFile) { Get-Content $respFile -TotalCount 20 }
exit 1
}
Write-Host "attached $name to release $id ($tag)"
}