Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions .github/workflows/gamelib-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: GameLibrary Android app

# Builds GameLibrary-android.apk (apps/gamelib/android/: a full-screen window around the web app), signs it with the key in the
# repository's secrets, opens it on an emulator and puts it on the gamelib-android release.
on:
workflow_dispatch:
push:
branches: [main]
paths:
- "apps/gamelib/android/**"
- ".github/workflows/gamelib-android.yml"
pull_request:
paths:
- "apps/gamelib/android/**"
- ".github/workflows/gamelib-android.yml"

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"

- name: "Build and sign the .apk (no Gradle: aapt2, javac, d8, zipalign, apksigner)"
env:
KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }}
KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
run: |
tools=$(ls -d "$ANDROID_HOME"/build-tools/34.* 2>/dev/null | sort -V | tail -n 1)
if [ -z "$tools" ]; then tools=$(ls -d "$ANDROID_HOME"/build-tools/* | sort -V | tail -n 1); fi
platform="$ANDROID_HOME/platforms/android-34"
if [ ! -f "$platform/android.jar" ]; then platform=$(ls -d "$ANDROID_HOME"/platforms/android-* | sort -V | tail -n 1); fi
export ANDROID_BUILD_TOOLS="$tools" ANDROID_JAR="$platform/android.jar"
echo "build-tools: $tools, platform: $platform"
if [ -n "$KEYSTORE_B64" ]; then
echo "$KEYSTORE_B64" | base64 -d > "$RUNNER_TEMP/release.p12"
printf '%s' "$KEYSTORE_PASSWORD" > "$RUNNER_TEMP/release-password.txt"
python3 apps/gamelib/android/build.py --keystore "$RUNNER_TEMP/release.p12" --password-file "$RUNNER_TEMP/release-password.txt" --alias shells
echo "SIGNED=release" >> "$GITHUB_ENV"
else
echo "::warning::No signing key secret here (a pull request from a fork): signed with a throwaway key."
python3 apps/gamelib/android/build.py
echo "SIGNED=throwaway" >> "$GITHUB_ENV"
fi
echo "APKSIGNER=$tools/apksigner" >> "$GITHUB_ENV"

- name: The certificate is the one app.json names
if: env.SIGNED == 'release'
run: |
expected=$(python3 -c "import json; print(json.load(open('apps/gamelib/android/app.json'))['certSha256'])")
found=$("$APKSIGNER" verify --print-certs apps/gamelib/android/dist/GameLibrary-android.apk | sed -n 's/^Signer #1 certificate SHA-256 digest: //p')
echo "expected $expected"
echo "found $found"
[ "$expected" = "$found" ]
(cd apps/gamelib/android/dist && sha256sum GameLibrary-android.apk > GameLibrary-android.apk.sha256 && cat GameLibrary-android.apk.sha256)

- uses: actions/upload-artifact@v4
with:
name: gamelib-android
path: apps/gamelib/android/dist/
if-no-files-found: error

emulator:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: gamelib-android
path: apps/gamelib/android/dist
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Open the app on an emulator and check it stays up
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
target: google_apis
arch: x86_64
profile: pixel_6
disable-animations: true
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none
script: python3 apps/gamelib/android/smoke.py apps/gamelib/android/dist/GameLibrary-android.apk
- uses: actions/upload-artifact@v4
if: always()
with:
name: gamelib-android-emulator-check
path: |
apps/gamelib/android/dist/*.png
apps/gamelib/android/dist/android-logcat.txt
retention-days: 7

publish:
needs: [build, emulator]
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: gamelib-android
path: dist
# The gamelib-android release keeps one address for the download. The file there is replaced only when
# apps/gamelib/android/app.json names a new versionName, never by a rebuild of the same version.
- name: Put the .apk on the gamelib-android release
env:
GH_TOKEN: ${{ github.token }}
run: |
version=$(python3 -c "import json; print(json.load(open('apps/gamelib/android/app.json'))['versionName'])")
echo "$version" > dist/GameLibrary-android.version.txt
if ! gh release view gamelib-android --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
printf '%s\n' "Game Library for Android: a full-screen window around the web app (https://juw12.github.io/projects/gamelib/)." "" \
"Download [GameLibrary-android.apk](https://github.com/$GITHUB_REPOSITORY/releases/download/gamelib-android/GameLibrary-android.apk), open the file on the phone and allow \"install unknown apps\" for your browser once." \
"It is not from a store: Android asks before it installs." > notes.md
gh release create gamelib-android dist/GameLibrary-android.apk dist/GameLibrary-android.apk.sha256 dist/GameLibrary-android.version.txt \
--title "Game Library for Android" --notes-file notes.md --latest=false --repo "$GITHUB_REPOSITORY"
echo "Made the gamelib-android release with GameLibrary-android.apk $version"
exit 0
fi
published=$(gh release download gamelib-android --repo "$GITHUB_REPOSITORY" --pattern GameLibrary-android.version.txt --output - 2>/dev/null || true)
if [ "$published" = "$version" ]; then
echo "the gamelib-android release already has GameLibrary-android.apk $version"
exit 0
fi
gh release upload gamelib-android dist/GameLibrary-android.apk dist/GameLibrary-android.apk.sha256 dist/GameLibrary-android.version.txt --clobber --repo "$GITHUB_REPOSITORY"
echo "GameLibrary-android.apk on the gamelib-android release is now $version (was: ${published:-none})"
177 changes: 177 additions & 0 deletions .github/workflows/gamelib-desktop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: GameLibrary apps

# Builds the downloadable GameLibrary apps and publishes them to the "gamelib-desktop" release from main:
# Windows GameLibrary-Windows-Setup.exe (per-user installer) + GameLibrary-Windows-Portable.zip
# macOS GameLibrary-macOS-AppleSilicon.dmg + GameLibrary-macOS-Intel.dmg
# The apps are thin native windows around the live site, so every push to the site reaches them through GitHub
# Pages without a rebuild. This workflow only runs when the shell in desktop/ changes. Every build is opened and
# checked on its own system first; only builds that passed are published, and the download links never change.
on:
push:
branches: [main]
paths:
- 'apps/gamelib/desktop/**'
- '.github/workflows/gamelib-desktop.yml'
pull_request:
paths:
- 'apps/gamelib/desktop/**'
- '.github/workflows/gamelib-desktop.yml'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: gamelib-desktop-${{ github.ref }}
cancel-in-progress: true

jobs:
desktop:
name: Desktop (${{ matrix.name }})
strategy:
fail-fast: false
matrix:
include:
- name: Windows
os: windows-latest
- name: macOS Apple silicon
os: macos-15
- name: macOS Intel
os: macos-15-intel
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install PyInstaller, Pillow and pywebview
run: python -m pip install --disable-pip-version-check pyinstaller pillow pywebview
- name: Install Inno Setup
if: runner.os == 'Windows'
shell: pwsh
run: |
$iscc = Join-Path ${env:ProgramFiles(x86)} 'Inno Setup 6\ISCC.exe'
if (-not (Test-Path $iscc) -and -not (Get-Command iscc -ErrorAction SilentlyContinue)) {
choco install innosetup --no-progress -y
}
- name: Make sure the WebView2 runtime is there (the Windows window uses it)
if: runner.os == 'Windows'
shell: pwsh
run: |
$client = '{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}'
$keys = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\$client",
"HKCU:\Software\Microsoft\EdgeUpdate\Clients\$client"
$version = $keys | Where-Object { Test-Path $_ } | ForEach-Object { (Get-ItemProperty $_).pv } |
Where-Object { $_ -and $_ -ne '0.0.0.0' } | Select-Object -First 1
if ($version) { Write-Host "WebView2 runtime $version"; exit 0 }
$setup = Join-Path $env:RUNNER_TEMP 'MicrosoftEdgeWebview2Setup.exe'
Invoke-WebRequest 'https://go.microsoft.com/fwlink/p/?LinkId=2124703' -OutFile $setup
Start-Process -FilePath $setup -ArgumentList '/silent', '/install' -Wait
- name: Stop XProtect scans (they make hdiutil fail with "Resource busy")
if: runner.os == 'macOS'
run: |
sudo pkill -9 XProtect > /dev/null 2>&1 || true
for attempt in $(seq 1 20); do pgrep -x XProtect > /dev/null || break; sleep 3; done
- name: Build and package
run: python apps/gamelib/desktop/build.py --require-installer
- name: Open the built app and check its window shows this commit's GameLibrary
run: python apps/gamelib/desktop/smoke_test.py --built --local-site
- name: Install with GameLibrary-Windows-Setup.exe, run it, uninstall it
if: runner.os == 'Windows'
shell: pwsh
run: |
$setup = Resolve-Path 'apps/gamelib/desktop/dist/GameLibrary-Windows-Setup.exe'
$log = Join-Path $env:RUNNER_TEMP 'gamelib-setup.log'
$process = Start-Process -FilePath $setup -Wait -PassThru -ArgumentList @(
'/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', '/TASKS=desktopicon', "/LOG=$log")
if ($process.ExitCode -ne 0) { Get-Content $log -Tail 40; throw "Setup failed with exit code $($process.ExitCode)" }
$app = Join-Path $env:LOCALAPPDATA 'Programs\GameLibrary\GameLibrary.exe'
if (-not (Test-Path $app)) { throw "GameLibrary.exe was not installed to $app" }
$shortcuts = @(
(Join-Path ([Environment]::GetFolderPath('Programs')) 'GameLibrary.lnk'),
(Join-Path ([Environment]::GetFolderPath('Desktop')) 'GameLibrary.lnk'))
foreach ($link in $shortcuts) { if (-not (Test-Path $link)) { throw "Missing shortcut: $link" } }
$entry = Get-ChildItem 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall' |
Get-ItemProperty | Where-Object DisplayName -eq 'GameLibrary'
if (-not $entry) { throw 'GameLibrary is missing from Settings > Apps' }
python apps/gamelib/desktop/smoke_test.py --local-site $app
if ($LASTEXITCODE -ne 0) { throw 'The installed app failed its checks' }
Start-Process -FilePath $entry.UninstallString.Trim('"') -Wait -ArgumentList '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART'
for ($i = 0; $i -lt 60 -and (Test-Path $app); $i++) { Start-Sleep -Seconds 1 }
if (Test-Path $app) { throw 'Uninstalling left GameLibrary.exe behind' }
foreach ($link in $shortcuts) { if (Test-Path $link) { throw "Uninstalling left a shortcut: $link" } }
Write-Host 'Installed, ran and uninstalled cleanly'
- name: Check the Mac app and disk image
if: runner.os == 'macOS'
run: |
APP=apps/gamelib/desktop/dist/GameLibrary.app
test "$(plutil -extract CFBundleIdentifier raw "$APP/Contents/Info.plist")" = "io.github.juw12.gamelib.desktop"
test "$(plutil -extract CFBundleShortVersionString raw "$APP/Contents/Info.plist")" = "$(python3 -c 'import json; print(json.load(open("apps/gamelib/desktop/shell.json"))["version"])')"
echo "Architecture: $(lipo -archs "$APP/Contents/MacOS/GameLibrary")"
codesign --verify --deep --verbose=2 "$APP"
for image in apps/gamelib/desktop/dist/*.dmg; do hdiutil verify "$image"; done
- uses: actions/upload-artifact@v4
with:
name: GameLibrary-${{ runner.os }}-${{ runner.arch }}
path: apps/gamelib/desktop/dist/GameLibrary-*
if-no-files-found: error
retention-days: 14

publish:
needs: [desktop]
if: ${{ !cancelled() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: GameLibrary-*
path: dist
merge-multiple: true
- name: Publish the apps to the apps release
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
run: |
cd dist
FILES=""
for name in GameLibrary-Windows-Setup.exe GameLibrary-Windows-Portable.zip \
GameLibrary-macOS-AppleSilicon.dmg GameLibrary-macOS-Intel.dmg; do
if [ -f "$name" ]; then
FILES="$FILES $name"
else
echo "::warning::$name was not built in this run; the release keeps its previous copy (if any)."
fi
done
if [ -z "$FILES" ]; then
echo "::error::No app passed its checks."
exit 1
fi
sha256sum $FILES > SHA256SUMS.txt
cat SHA256SUMS.txt
cat > notes.md <<'EOF'
**Game Library**: a searchable collection of browser games by category. The apps open the same Game Library as https://juw12.github.io/projects/gamelib/ in their own window.

| Your device | Download | How to install |
| --- | --- | --- |
| **Windows 10/11** | [GameLibrary-Windows-Setup.exe](https://github.com/juw12/projects/releases/download/gamelib-desktop/GameLibrary-Windows-Setup.exe) | Open it and press Install (no admin needed). If Windows says it protected your PC, choose **More info → Run anyway** (the app is not code-signed yet). Without installing: [GameLibrary-Windows-Portable.zip](https://github.com/juw12/projects/releases/download/gamelib-desktop/GameLibrary-Windows-Portable.zip). |
| **Mac with Apple chip (M1 and newer)** | [GameLibrary-macOS-AppleSilicon.dmg](https://github.com/juw12/projects/releases/download/gamelib-desktop/GameLibrary-macOS-AppleSilicon.dmg) | Open it and drag GameLibrary to Applications. The first time, macOS blocks it because it is not notarized: **System Settings → Privacy & Security → Open Anyway**. |
| **Mac with Intel chip** | [GameLibrary-macOS-Intel.dmg](https://github.com/juw12/projects/releases/download/gamelib-desktop/GameLibrary-macOS-Intel.dmg) | Same as above. Not sure which Mac? Apple menu → About This Mac shows **Chip** (Apple) or **Processor** (Intel). |
| **iPhone / iPad** | [Open in Safari](https://juw12.github.io/projects/gamelib/) | Share → **Add to Home Screen** (free, full screen, updates itself). |
| **Android** | [GameLibrary-android.apk](https://github.com/juw12/projects/releases/download/gamelib-android/GameLibrary-android.apk) | Open the file on the phone and allow your browser to install apps once. |

The apps load GameLibrary from the web, so new versions arrive the moment they are published, with no reinstall. Checksums for this build: `SHA256SUMS.txt`.
EOF
{
echo
echo "Built from ${GITHUB_SHA::7}."
} >> notes.md
if gh release view gamelib-desktop --repo "$REPO" > /dev/null 2>&1; then
gh release upload gamelib-desktop $FILES SHA256SUMS.txt --clobber --repo "$REPO"
gh release edit gamelib-desktop --notes-file notes.md --repo "$REPO"
else
gh release create gamelib-desktop $FILES SHA256SUMS.txt --title "Game Library for Windows and Mac" \
--notes-file notes.md --latest=false --repo "$REPO"
fi
9 changes: 9 additions & 0 deletions apps/gamelib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ access control: the source and direct game URLs remain public.
Browser-only saves belong to the browser origin and do not automatically move
from the old `juwpegatron.github.io` website to `juw12.github.io`.

## Get it on your device

- **Windows:** [`GameLibrary-Windows-Setup.exe`](https://github.com/juw12/projects/releases/download/gamelib-desktop/GameLibrary-Windows-Setup.exe) (no admin needed; if Windows says it protected your PC, choose *More info → Run anyway*), or without installing [`GameLibrary-Windows-Portable.zip`](https://github.com/juw12/projects/releases/download/gamelib-desktop/GameLibrary-Windows-Portable.zip).
- **Mac:** [`GameLibrary-macOS-AppleSilicon.dmg`](https://github.com/juw12/projects/releases/download/gamelib-desktop/GameLibrary-macOS-AppleSilicon.dmg) (M1 and newer) or [`GameLibrary-macOS-Intel.dmg`](https://github.com/juw12/projects/releases/download/gamelib-desktop/GameLibrary-macOS-Intel.dmg). The first time, macOS blocks it because it is not notarized: **System Settings → Privacy & Security → Open Anyway**.
- **Android:** [`GameLibrary-android.apk`](https://github.com/juw12/projects/releases/download/gamelib-android/GameLibrary-android.apk): open the file on the phone and allow your browser to install apps once.
- **iPhone:** open https://juw12.github.io/projects/gamelib/ in Safari, tap Share, then **Add to Home Screen**.

The Windows, Mac and Android apps are the web app in its own window ([`desktop/`](desktop/README.md), [`android/`](android/README.md)) and change with it. Each build is opened on GitHub's machines before it is published: on Windows and on a Mac the page loads, the app starts and can store data; on an Android emulator it installs, opens and stays up. They are not code-signed or notarised, and no real phone or PC has run them yet.

## Sharp canvases on 2x and 3x screens

Most games draw into a canvas of a fixed size (for example 900 x 480) that the browser stretches over a
Expand Down
2 changes: 2 additions & 0 deletions apps/gamelib/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
dist/
23 changes: 23 additions & 0 deletions apps/gamelib/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.github.juw12.gamelib">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="Game Library"
android:icon="@mipmap/ic_launcher"
android:theme="@style/App"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:usesCleartextTraffic="false">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|keyboard|keyboardHidden|uiMode|density">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Loading
Loading