Skip to content

Merge branch 'embedded-swift-no-foundation' #46

Merge branch 'embedded-swift-no-foundation'

Merge branch 'embedded-swift-no-foundation' #46

name: Build Windows WebView (Swift WASM)
on:
push:
branches: [main]
paths:
- 'boss-man-windows-webview/**'
- 'boss-man-spritekit-web/**'
- '.github/workflows/build-windows-webview.yml'
tags: ['pre-*']
workflow_dispatch:
permissions:
contents: write
id-token: write
jobs:
build-wasm:
name: Build Swift WASM
runs-on: macos-15
env:
SWIFT_VERSION: 6.3.2
steps:
- uses: actions/checkout@v4
- name: Install Swift ${{ env.SWIFT_VERSION }} toolchain
run: |
set -euo pipefail
PKG="swift-${SWIFT_VERSION}-RELEASE-osx.pkg"
URL="https://download.swift.org/swift-${SWIFT_VERSION}-release/xcode/swift-${SWIFT_VERSION}-RELEASE/${PKG}"
curl -fL --retry 3 -o "/tmp/${PKG}" "$URL"
installer -pkg "/tmp/${PKG}" -target CurrentUserHomeDirectory
TC_DIR=$(ls -d ~/Library/Developer/Toolchains/swift-${SWIFT_VERSION}-RELEASE*.xctoolchain | head -1)
TC_ID=$(/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" "$TC_DIR/Info.plist")
echo "TOOLCHAINS=$TC_ID" >> $GITHUB_ENV
- name: Install wasm SDK
run: |
set -euo pipefail
BUNDLE="swift-${SWIFT_VERSION}-RELEASE_wasm.artifactbundle.tar.gz"
BASE="https://download.swift.org/swift-${SWIFT_VERSION}-release/wasm-sdk/swift-${SWIFT_VERSION}-RELEASE"
curl -fL --retry 3 -o "/tmp/${BUNDLE}" "${BASE}/${BUNDLE}"
CHECKSUM=$(shasum -a 256 "/tmp/${BUNDLE}" | awk '{print $1}')
xcrun --toolchain "$TOOLCHAINS" swift sdk install "/tmp/${BUNDLE}" --checksum "${CHECKSUM}"
- name: Install wasm-opt (Binaryen)
run: brew install binaryen --quiet
- name: Build boss-man-spritekit-web
working-directory: boss-man-spritekit-web
run: SWIFT_TOOLCHAIN="$TOOLCHAINS" ./build.sh release
# pre-1.0.8-embedded: webview payloads ship the Embedded Swift wasm and
# the minified embedded runtime under the canonical names, so the pages
# and app loaders need no changes.
- name: Swap in Embedded wasm + minified runtime
run: |
set -euo pipefail
TOOLCHAINS="$TOOLCHAINS" bash docs/embedded/build-embedded-game.sh
cp boss-man-spritekit-web/web/bossman-embedded.wasm boss-man-spritekit-web/web/bossman.wasm
cp boss-man-spritekit-web/web/runtime-embedded-min.js boss-man-spritekit-web/web/runtime.js
- uses: actions/upload-artifact@v4
with:
name: swift-wasm-bundle-win
path: |
boss-man-spritekit-web/web/bossman.wasm
boss-man-spritekit-web/web/runtime.js
boss-man-spritekit-web/web/server.html
boss-man-spritekit-web/web/assets/
if-no-files-found: error
retention-days: 1
build-windows:
name: Windows ${{ matrix.arch }}
needs: build-wasm
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- arch: x64
runner: windows-latest
rid: win-x64
- arch: arm64
runner: windows-11-arm
rid: win-arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- uses: actions/download-artifact@v4
with:
name: swift-wasm-bundle-win
path: swift-wasm-bundle
- name: Build
working-directory: boss-man-windows-webview
run: |
dotnet publish -r ${{ matrix.rid }} -c Release --self-contained false -o dist
- name: Bundle play files
shell: pwsh
run: |
$play = "boss-man-windows-webview/dist/play"
New-Item -ItemType Directory -Force -Path $play | Out-Null
$src = "swift-wasm-bundle"
Copy-Item "$src/server.html" $play
Copy-Item "$src/runtime.js" $play
Copy-Item "$src/bossman.wasm" $play
Copy-Item "$src/assets" $play -Recurse
Compress-Archive -Path boss-man-windows-webview/dist/* `
-DestinationPath "Boss-Man-Windows-${{ matrix.arch }}.zip"
# Sigstore signing needs a prebuilt cryptography wheel; only x64 Windows
# runners have one. arm64 falls back to a Rust source build that has no
# OpenSSL/cargo and fails, so sign x64 only and ship arm64 unsigned.
- uses: sigstore/gh-action-sigstore-python@v3.3.0
if: matrix.arch == 'x64'
with:
inputs: Boss-Man-Windows-${{ matrix.arch }}.zip
- uses: actions/upload-artifact@v4
with:
name: boss-man-windows-webview-${{ matrix.arch }}
path: |
Boss-Man-Windows-${{ matrix.arch }}.zip
Boss-Man-Windows-${{ matrix.arch }}.zip.sigstore.json
if-no-files-found: error
- name: Attach to GitHub Release
if: startsWith(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
TAG="${GITHUB_REF_NAME}"
gh release view "$TAG" >/dev/null 2>&1 || \
gh release create "$TAG" --title "$TAG" --notes "" --prerelease
files=("Boss-Man-Windows-${{ matrix.arch }}.zip")
[ -f "Boss-Man-Windows-${{ matrix.arch }}.zip.sigstore.json" ] && \
files+=("Boss-Man-Windows-${{ matrix.arch }}.zip.sigstore.json")
gh release upload "$TAG" "${files[@]}" --clobber