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/peers-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Peers Android app

# Builds Peers-android.apk (apps/peers/shell/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 peers-android release.
on:
workflow_dispatch:
push:
branches: [main]
paths:
- "apps/peers/shell/android/**"
- ".github/workflows/peers-android.yml"
pull_request:
paths:
- "apps/peers/shell/android/**"
- ".github/workflows/peers-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/peers/shell/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/peers/shell/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/peers/shell/android/app.json'))['certSha256'])")
found=$("$APKSIGNER" verify --print-certs apps/peers/shell/android/dist/Peers-android.apk | sed -n 's/^Signer #1 certificate SHA-256 digest: //p')
echo "expected $expected"
echo "found $found"
[ "$expected" = "$found" ]
(cd apps/peers/shell/android/dist && sha256sum Peers-android.apk > Peers-android.apk.sha256 && cat Peers-android.apk.sha256)

- uses: actions/upload-artifact@v4
with:
name: peers-android
path: apps/peers/shell/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: peers-android
path: apps/peers/shell/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/peers/shell/android/smoke.py apps/peers/shell/android/dist/Peers-android.apk
- uses: actions/upload-artifact@v4
if: always()
with:
name: peers-android-emulator-check
path: |
apps/peers/shell/android/dist/*.png
apps/peers/shell/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: peers-android
path: dist
# The peers-android release keeps one address for the download. The file there is replaced only when
# apps/peers/shell/android/app.json names a new versionName, never by a rebuild of the same version.
- name: Put the .apk on the peers-android release
env:
GH_TOKEN: ${{ github.token }}
run: |
version=$(python3 -c "import json; print(json.load(open('apps/peers/shell/android/app.json'))['versionName'])")
echo "$version" > dist/Peers-android.version.txt
if ! gh release view peers-android --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
printf '%s\n' "Peers for Android: a full-screen window around the web app (https://juw12.github.io/projects/peers/)." "" \
"Download [Peers-android.apk](https://github.com/$GITHUB_REPOSITORY/releases/download/peers-android/Peers-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 peers-android dist/Peers-android.apk dist/Peers-android.apk.sha256 dist/Peers-android.version.txt \
--title "Peers for Android" --notes-file notes.md --latest=false --repo "$GITHUB_REPOSITORY"
echo "Made the peers-android release with Peers-android.apk $version"
exit 0
fi
published=$(gh release download peers-android --repo "$GITHUB_REPOSITORY" --pattern Peers-android.version.txt --output - 2>/dev/null || true)
if [ "$published" = "$version" ]; then
echo "the peers-android release already has Peers-android.apk $version"
exit 0
fi
gh release upload peers-android dist/Peers-android.apk dist/Peers-android.apk.sha256 dist/Peers-android.version.txt --clobber --repo "$GITHUB_REPOSITORY"
echo "Peers-android.apk on the peers-android release is now $version (was: ${published:-none})"
172 changes: 172 additions & 0 deletions .github/workflows/peers-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: Peers apps

# Builds the downloadable Peers apps and publishes them to the "peers-mac" release from main:
# macOS Peers-macOS-AppleSilicon.dmg + Peers-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/peers/shell/desktop/**'
- '.github/workflows/peers-mac.yml'
pull_request:
paths:
- 'apps/peers/shell/desktop/**'
- '.github/workflows/peers-mac.yml'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: peers-mac-${{ github.ref }}
cancel-in-progress: true

jobs:
desktop:
name: Desktop (${{ matrix.name }})
strategy:
fail-fast: false
matrix:
include:
- 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/peers/shell/desktop/build.py --require-installer
- name: Open the built app and check its window shows this commit's Peers
run: python apps/peers/shell/desktop/smoke_test.py --built --local-site
- name: Install with Peers-Windows-Setup.exe, run it, uninstall it
if: runner.os == 'Windows'
shell: pwsh
run: |
$setup = Resolve-Path 'apps/peers/shell/desktop/dist/Peers-Windows-Setup.exe'
$log = Join-Path $env:RUNNER_TEMP 'peers-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\Peers\Peers.exe'
if (-not (Test-Path $app)) { throw "Peers.exe was not installed to $app" }
$shortcuts = @(
(Join-Path ([Environment]::GetFolderPath('Programs')) 'Peers.lnk'),
(Join-Path ([Environment]::GetFolderPath('Desktop')) 'Peers.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 'Peers'
if (-not $entry) { throw 'Peers is missing from Settings > Apps' }
python apps/peers/shell/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 Peers.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/peers/shell/desktop/dist/Peers.app
test "$(plutil -extract CFBundleIdentifier raw "$APP/Contents/Info.plist")" = "io.github.juw12.peers.desktop"
test "$(plutil -extract CFBundleShortVersionString raw "$APP/Contents/Info.plist")" = "$(python3 -c 'import json; print(json.load(open("apps/peers/shell/desktop/shell.json"))["version"])')"
echo "Architecture: $(lipo -archs "$APP/Contents/MacOS/Peers")"
codesign --verify --deep --verbose=2 "$APP"
for image in apps/peers/shell/desktop/dist/*.dmg; do hdiutil verify "$image"; done
- uses: actions/upload-artifact@v4
with:
name: Peers-${{ runner.os }}-${{ runner.arch }}
path: apps/peers/shell/desktop/dist/Peers-*
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: Peers-*
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 Peers-macOS-AppleSilicon.dmg Peers-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'
**Peers**: verified reviews from real people. The apps open the same Peers as https://juw12.github.io/projects/peers/ in their own window.

| Your device | Download | How to install |
| --- | --- | --- |
| **Mac with Apple chip (M1 and newer)** | [Peers-macOS-AppleSilicon.dmg](https://github.com/juw12/projects/releases/download/peers-mac/Peers-macOS-AppleSilicon.dmg) | Open it and drag Peers to Applications. The first time, macOS blocks it because it is not notarized: **System Settings → Privacy & Security → Open Anyway**. |
| **Mac with Intel chip** | [Peers-macOS-Intel.dmg](https://github.com/juw12/projects/releases/download/peers-mac/Peers-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/peers/) | Share → **Add to Home Screen** (free, full screen, updates itself). |
| **Android** | [Peers-android.apk](https://github.com/juw12/projects/releases/download/peers-android/Peers-android.apk) | Open the file on the phone and allow your browser to install apps once. |

The apps load Peers 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 peers-mac --repo "$REPO" > /dev/null 2>&1; then
gh release upload peers-mac $FILES SHA256SUMS.txt --clobber --repo "$REPO"
gh release edit peers-mac --notes-file notes.md --repo "$REPO"
else
gh release create peers-mac $FILES SHA256SUMS.txt --title "Peers for Mac" \
--notes-file notes.md --latest=false --repo "$REPO"
fi
16 changes: 16 additions & 0 deletions apps/peers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@
</p>
<!-- HERO:END -->

## On a Mac

- **Mac:** [`Peers-macOS-AppleSilicon.dmg`](https://github.com/juw12/projects/releases/download/peers-mac/Peers-macOS-AppleSilicon.dmg) (M1 and newer) or [`Peers-macOS-Intel.dmg`](https://github.com/juw12/projects/releases/download/peers-mac/Peers-macOS-Intel.dmg). Open it and drag Peers to Applications. The first time, macOS blocks it because it is not notarized: **System Settings → Privacy & Security → Open Anyway**.

It is the web edition (https://juw12.github.io/projects/peers/) in its own window ([`desktop/`](shell/desktop/README.md)) and changes with it. Each build is opened on an Apple-silicon Mac and an Intel Mac on GitHub before it is published: the page loads, the app starts and can store data. No Mac of ours has run it yet.

## On an Android phone

- **Android:** [`Peers-android.apk`](https://github.com/juw12/projects/releases/download/peers-android/Peers-android.apk): open the file on the phone and allow your browser to install apps once.

It is the web app (https://juw12.github.io/projects/peers/) in a full-screen window of its own ([`android/`](shell/android/README.md)) and changes with it. The build is opened on an Android emulator on GitHub before it is published: it installs, opens and stays up. No real phone has run it yet.

## On an iPhone

- **iPhone:** open https://juw12.github.io/projects/peers/ in Safari, tap Share, then **Add to Home Screen**.

## About

Peers is a client-side photo demo application that showcases a responsive photo gallery interface. The app is built as a **single-file HTML** with all CSS and JavaScript embedded inline, requiring no build process or backend server to run.
Expand Down
2 changes: 2 additions & 0 deletions apps/peers/shell/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/peers/shell/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.peers">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="Peers"
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