mirror of
https://github.com/db9979/uconsole_asw_game.git
synced 2026-12-06 21:04:18 +01:00
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Nnvw4QEQCCWoLWoB9ba6h
94 lines
3.6 KiB
YAML
94 lines
3.6 KiB
YAML
# Builds the Windows program (U-Jagd-Windows.exe: starter window + 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 }
|
|
|
|
- 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
|