ci: build the Windows client on GitHub and Gitea

GitHub builds natively on windows-latest; Gitea cross-compiles with MinGW
on a Linux runner. Both upload the client with its assets and publish a
zip for v* tags.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Steve Biedermann 2026-10-18 19:44:13 +02:00
parent a43949be14
commit 9ffca14d8d
2 changed files with 130 additions and 0 deletions

View File

@ -0,0 +1,69 @@
# Gitea Actions: cross-compiles the Windows client on a Linux runner with MinGW,
# since most Gitea runners are Linux containers.
name: Windows client
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
TARGET: x86_64-pc-windows-gnu
jobs:
build:
name: Build Windows client
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install MinGW
run: |
SUDO=$(command -v sudo || true)
$SUDO apt-get update
$SUDO apt-get install -y --no-install-recommends gcc-mingw-w64-x86-64 zip
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ env.TARGET }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: windows-gnu-${{ hashFiles('Cargo.lock') }}
restore-keys: windows-gnu-
- name: Build
run: cargo build --release --locked -p game_client --bin game --target "$TARGET"
- name: Package
run: |
dist=dist/station-windows
mkdir -p "$dist"
cp "target/$TARGET/release/game.exe" "$dist/"
cp -r assets README.md "$dist/"
(cd dist && zip -qr station-windows.zip station-windows)
# Gitea does not support upload-artifact v4.
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: station-windows
path: dist/station-windows
if-no-files-found: error
- name: Publish release
if: startsWith(github.ref, 'refs/tags/v')
uses: https://gitea.com/actions/release-action@main
with:
files: dist/station-windows.zip
api_key: ${{ secrets.GITHUB_TOKEN }}

61
.github/workflows/windows-client.yml vendored Normal file
View File

@ -0,0 +1,61 @@
name: Windows client
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
jobs:
build:
name: Build Windows client
runs-on: windows-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --release --locked -p game_client --bin game
- name: Package
shell: pwsh
run: |
$dist = "dist/station-windows"
New-Item -ItemType Directory -Force -Path $dist | Out-Null
Copy-Item target/release/game.exe $dist/
Copy-Item -Recurse assets $dist/assets
Copy-Item README.md $dist/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: station-windows
path: dist/station-windows
if-no-files-found: error
- name: Create release archive
if: startsWith(github.ref, 'refs/tags/v')
shell: pwsh
run: Compress-Archive -Path dist/station-windows/* -DestinationPath dist/station-windows.zip
- name: Publish release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: dist/station-windows.zip