mirror of
https://github.com/db9979/uconsole_asw_game.git
synced 2026-12-06 12:54:18 +01:00
The Tk starter stays deleted: the frozen game installs updates itself
("windows" mode); src/launcher/entry.py takes over the starter's
UPDATE_EXIT_CODE hand-over (fetch <exe>.new if missing, launch_install).
main.py keeps --multiplayer and passes mode None to start_update_check;
launcher.* catalog keys stay removed next to the new update.* keys.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CdekJguPyu1j8yasw3BYWx
144 lines
6.2 KiB
YAML
144 lines
6.2 KiB
YAML
# Builds the Windows program (U-Jagd-Windows.exe, starts straight into the game) on
|
|
# every push and pull request. A push to main publishes it as the GitHub
|
|
# release "v<APP_VERSION>"; the program's update check reads that release.
|
|
name: Windows program
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
concurrency:
|
|
group: windows-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: windows-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install dependencies
|
|
run: python -m pip install -e ".[windows]"
|
|
|
|
- name: Read version
|
|
id: version
|
|
shell: bash
|
|
run: echo "version=$(python -c 'from src.core.version import APP_VERSION; print(APP_VERSION)')" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Build U-Jagd-Windows.exe
|
|
run: pyinstaller --noconfirm packaging/windows/u-jagd-windows.spec
|
|
|
|
- name: Self-test the built program
|
|
shell: pwsh
|
|
run: |
|
|
$report = Join-Path $env:RUNNER_TEMP "selftest.json"
|
|
$p = Start-Process -FilePath dist\U-Jagd-Windows.exe -ArgumentList "--self-test", "`"$report`"" -Wait -PassThru
|
|
Get-Content $report
|
|
if ($p.ExitCode -ne 0) { exit 1 }
|
|
|
|
- name: Self-test a restart after a self-update
|
|
# The update restarts the swapped exe from a process that carries the
|
|
# old one's extraction variables; it must unpack afresh (1.3.17 fix).
|
|
shell: pwsh
|
|
run: |
|
|
$exe = (Resolve-Path dist\U-Jagd-Windows.exe).Path
|
|
$report = Join-Path $env:RUNNER_TEMP "selftest-update.json"
|
|
$env:_PYI_APPLICATION_HOME_DIR = Join-Path $env:TEMP "_MEI000gone"
|
|
$env:_PYI_ARCHIVE_FILE = $exe
|
|
$env:_PYI_PARENT_PROCESS_LEVEL = "1"
|
|
$env:PYINSTALLER_RESET_ENVIRONMENT = "1"
|
|
$p = Start-Process -FilePath $exe -ArgumentList "--self-test", "`"$report`"" -Wait -PassThru
|
|
Get-Content $report
|
|
if ($p.ExitCode -ne 0) { exit 1 }
|
|
|
|
- name: Self-test the update swap
|
|
# "Install update" end to end: the running exe starts the install
|
|
# script and exits; the script must replace it with <exe>.new and start
|
|
# the new file (1.3.73 fix: it used to leave .new and restart the old).
|
|
shell: pwsh
|
|
run: |
|
|
$dir = Join-Path $env:RUNNER_TEMP "update-test"
|
|
New-Item -ItemType Directory -Force $dir | Out-Null
|
|
$exe = Join-Path $dir "U-Jagd-Windows.exe"
|
|
Copy-Item dist\U-Jagd-Windows.exe $exe
|
|
Copy-Item dist\U-Jagd-Windows.exe "$exe.new"
|
|
$report = Join-Path $env:RUNNER_TEMP "selftest-swap.json"
|
|
$p = Start-Process -FilePath $exe -ArgumentList "--update-self-test", "`"$report`"" -Wait -PassThru
|
|
if ($p.ExitCode -ne 0) { Write-Error "update self-test exited with $($p.ExitCode)"; exit 1 }
|
|
$deadline = (Get-Date).AddMinutes(5)
|
|
$result = $null
|
|
while ($null -eq $result -and (Get-Date) -lt $deadline) {
|
|
try { $result = Get-Content $report -Raw -ErrorAction Stop | ConvertFrom-Json } catch { Start-Sleep 2 }
|
|
}
|
|
if ($null -eq $result) { Write-Error "the swapped program did not start"; exit 1 }
|
|
Get-Content $report
|
|
if (Test-Path "$exe.new") { Write-Error "the update was left as .new"; exit 1 }
|
|
if (-not $result.ok) { exit 1 }
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: U-Jagd-Windows-${{ steps.version.outputs.version }}
|
|
path: dist/U-Jagd-Windows.exe
|
|
|
|
- name: Publish release
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
shell: bash
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
VERSION: ${{ steps.version.outputs.version }}
|
|
run: |
|
|
# One release per version, shared with other build jobs (for example
|
|
# the uConsole package): create it if missing, then add this asset
|
|
# unless it is already there. Never replace a published asset.
|
|
tag="v$VERSION"
|
|
if ! gh release view "$tag" >/dev/null 2>&1; then
|
|
# Release text: this version's CHANGELOG.md entry plus the Windows hint.
|
|
{ python tools/changelog_notes.py "$VERSION" || echo "U-Jagd $VERSION."
|
|
echo
|
|
echo "Windows: download U-Jagd-Windows.exe and run it; it offers later versions itself."
|
|
} > release-notes.md
|
|
gh release create "$tag" --target "$GITHUB_SHA" --title "U-Jagd $VERSION" \
|
|
--notes-file release-notes.md \
|
|
|| gh release view "$tag" >/dev/null
|
|
fi
|
|
if gh release view "$tag" --json assets --jq '.assets[].name' | grep -qx "U-Jagd-Windows.exe"; then
|
|
echo "U-Jagd-Windows.exe is already published for $tag; bump src/core/version.py for a new build."
|
|
else
|
|
gh release upload "$tag" dist/U-Jagd-Windows.exe
|
|
fi
|
|
|
|
- name: Remove older releases and tags
|
|
# Only the newest release and its tag stay on GitHub (Dominik,
|
|
# 2026-09-28/29). Both updaters read releases/latest only; the uConsole
|
|
# updater fetches just that tag. Tags not named vX.Y.Z are kept.
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
shell: bash
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
VERSION: ${{ steps.version.outputs.version }}
|
|
run: |
|
|
gh release view "v$VERSION" --json assets --jq '.assets[].name' | grep -qx "U-Jagd-Windows.exe"
|
|
gh api --paginate "repos/$GITHUB_REPOSITORY/releases?per_page=100" --jq '.[].tag_name' \
|
|
| python tools/prune_releases.py "$VERSION" \
|
|
| while read -r old; do
|
|
old=${old%$'\r'}
|
|
echo "Deleting release $old"
|
|
gh release delete "$old" --yes
|
|
done
|
|
gh api --paginate "repos/$GITHUB_REPOSITORY/tags?per_page=100" --jq '.[].name' \
|
|
| python tools/prune_releases.py "$VERSION" \
|
|
| while read -r old; do
|
|
old=${old%$'\r'}
|
|
echo "Deleting tag $old"
|
|
gh api -X DELETE "repos/$GITHUB_REPOSITORY/git/refs/tags/$old"
|
|
done
|