Merge branch 'embedded-swift-no-foundation' #45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Linux WebView (Swift WASM) | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'boss-man-linux-webview/**' | |
| - 'boss-man-spritekit-web/**' | |
| - '.github/workflows/build-linux-webview.yml' | |
| tags: ['pre-*'] | |
| workflow_dispatch: | |
| permissions: | |
| contents: 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-linux | |
| 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-linux: | |
| name: Linux ${{ matrix.arch }} | |
| needs: build-wasm | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: x86_64 | |
| deb_arch: amd64 | |
| runner: ubuntu-22.04 | |
| - arch: arm64 | |
| deb_arch: arm64 | |
| runner: ubuntu-22.04-arm | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install WebKit2GTK | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential cmake \ | |
| libgtk-3-dev \ | |
| libwebkit2gtk-4.1-dev | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: swift-wasm-bundle-linux | |
| path: swift-wasm-bundle | |
| - name: Build | |
| working-directory: boss-man-linux-webview | |
| run: | | |
| cmake -S . -B build -DCMAKE_BUILD_TYPE=Release | |
| cmake --build build -j"$(nproc)" | |
| - name: Bundle tar.gz | |
| run: | | |
| mkdir -p dist/play | |
| cp boss-man-linux-webview/build/BossMan dist/ | |
| cp swift-wasm-bundle/server.html dist/play/ | |
| cp swift-wasm-bundle/runtime.js dist/play/ | |
| cp swift-wasm-bundle/bossman.wasm dist/play/ | |
| cp -r swift-wasm-bundle/assets dist/play/ | |
| tar -czf Boss-Man-Linux-${{ matrix.arch }}.tar.gz -C dist . | |
| - name: Build .deb | |
| run: | | |
| DEB="deb-pkg" | |
| mkdir -p "$DEB/DEBIAN" \ | |
| "$DEB/usr/bin" \ | |
| "$DEB/usr/share/bossman/play/assets" \ | |
| "$DEB/usr/share/icons/hicolor/512x512/apps" \ | |
| "$DEB/usr/share/applications" | |
| cp boss-man-linux-webview/build/BossMan "$DEB/usr/bin/bossman" | |
| cp swift-wasm-bundle/server.html "$DEB/usr/share/bossman/play/" | |
| cp swift-wasm-bundle/runtime.js "$DEB/usr/share/bossman/play/" | |
| cp swift-wasm-bundle/bossman.wasm "$DEB/usr/share/bossman/play/" | |
| cp -r swift-wasm-bundle/assets/. "$DEB/usr/share/bossman/play/assets/" | |
| cp boss-man-linux-webview/bossman.png "$DEB/usr/share/icons/hicolor/512x512/apps/bossman.png" | |
| cp boss-man-linux-webview/bossman.desktop "$DEB/usr/share/applications/bossman.desktop" | |
| cat > "$DEB/DEBIAN/control" <<EOF | |
| Package: boss-man | |
| Version: 1.0.6 | |
| Architecture: ${{ matrix.deb_arch }} | |
| Maintainer: StarPlay RX <todd@starplayrx.com> | |
| Depends: libgtk-3-0, libwebkit2gtk-4.1-0 | |
| Description: Boss-Man arcade game (Swift WebAssembly + WebKit2GTK) | |
| EOF | |
| dpkg-deb --build "$DEB" Boss-Man-Linux-${{ matrix.arch }}.deb | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: boss-man-linux-webview-${{ matrix.arch }} | |
| path: | | |
| Boss-Man-Linux-${{ matrix.arch }}.tar.gz | |
| Boss-Man-Linux-${{ matrix.arch }}.deb | |
| if-no-files-found: error | |
| - name: Attach to GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| TAG="${GITHUB_REF_NAME}" | |
| gh release view "$TAG" >/dev/null 2>&1 || \ | |
| gh release create "$TAG" --title "$TAG" --notes "" --prerelease | |
| gh release upload "$TAG" \ | |
| Boss-Man-Linux-${{ matrix.arch }}.tar.gz \ | |
| Boss-Man-Linux-${{ matrix.arch }}.deb \ | |
| --clobber |