commit 66fe28c2bcb5bf166f1f110df7c29d1a9ee791a2
parent 1d1e850d483545fb8c982589681f01aeefd5035a
Author: Amit Dutta <mail@amit.is-a.dev>
Date: Fri, 28 Aug 2026 20:16:01 +0530
Merge pull request #102 from notamitgamer/refactor/merge-apk-content-into-main
Merge apk-content into main.yml — build the site once per push
Diffstat:
3 files changed, 85 insertions(+), 129 deletions(-)
diff --git a/.github/workflows/build-apk.yml b/.github/workflows/build-apk.yml
@@ -1,19 +1,5 @@
name: Build Offline APK
-# Fully separate from main.yml on purpose: if anything here misbehaves,
-# delete this file and the site build/deploy is completely unaffected.
-#
-# Fully separate from main.yml on purpose: if anything here misbehaves,
-# delete this file and the site build/deploy is completely unaffected.
-#
-# This builds the APK SHELL only (the installable app itself) — the
-# expensive part (Android SDK + Gradle). Manual trigger only: the
-# shell rarely if ever needs to change once the app is installed —
-# @capgo/capacitor-updater (baked into the shell) handles all content
-# updates on its own via update-apk-content.yml, which runs cheaply
-# on every push without touching Gradle at all. Run this only when
-# something about the native shell itself actually changes (app icon,
-# plugin versions, native config, etc.).
on:
workflow_dispatch:
inputs:
@@ -46,10 +32,6 @@ jobs:
- name: Install site deps
run: npm ci
- # main.yml runs these before the VitePress build — they generate
- # the per-folder index.md files (practice/index.md, etc.) that
- # the rest of the docs link to. Skipping them causes a
- # "dead link(s) found" build failure.
- name: Setup Python
uses: actions/setup-python@v5
with:
@@ -63,8 +45,6 @@ jobs:
- name: Build VitePress site
run: npm run docs:build
- # ubuntu-latest ships with Android SDK + a JDK preinstalled, so no
- # extra SDK download step is needed here.
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
@@ -76,7 +56,7 @@ jobs:
mkdir -p apk-build
cd apk-build
npm init -y
- npm install @capacitor/core @capacitor/cli @capacitor/android @capgo/capacitor-updater
+ npm install @capacitor/core @capacitor/cli @capacitor/android @capgo/capacitor-updater @capacitor/assets
mkdir -p www
cp -r ../docs/.vitepress/dist/. www/
@@ -99,20 +79,21 @@ jobs:
npx cap add android
npx cap sync android
+ - name: Generate Capacitor Assets (App Icon & Splash)
+ run: |
+ mkdir -p apk-build/assets
+ # Copy the 512x512 logo to the assets folder as icon and splash targets
+ cp docs/public/logo_512.png apk-build/assets/icon.png
+ cp docs/public/logo_512.png apk-build/assets/splash.png
+ cd apk-build
+ npx @capacitor/assets generate --android
+
- name: Bump Android compile SDK for okhttp-android
working-directory: apk-build/android
run: |
sed -Ei 's/(compileSdkVersion\s*=\s*)[0-9]+/\136/' variables.gradle
echo "android.suppressUnsupportedCompileSdk=36" >> gradle.properties
- # Repo secrets required, added once by hand under
- # Settings > Secrets and variables > Actions:
- # ANDROID_KEYSTORE_BASE64 base64 of the .keystore file
- # ANDROID_KEYSTORE_PASSWORD
- # ANDROID_KEY_ALIAS
- # ANDROID_KEY_PASSWORD
- # Same keystore must be reused for every future build — Android
- # rejects updates signed with a different key than the installed app.
- name: Decode signing keystore
working-directory: apk-build/android/app
env:
@@ -208,7 +189,7 @@ jobs:
- Works fully offline after install.
- Auto-pulls newer content when online, via the manifest at
apk-manifest/manifest.json (raw.githubusercontent.com) —
- kept up to date on every push by update-apk-content.yml,
+ kept up to date on every push by main.yml's apk-content job,
independently of this shell build.
files: |
${{ steps.apk.outputs.path }}
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
@@ -122,6 +122,16 @@ jobs:
with:
path: docs/.vitepress/dist
+ # Also stash the same build output as a plain artifact so the
+ # apk-content job below can reuse it — avoids running
+ # docs:build (and list.py/main.py) a second time for the same commit.
+ - name: Upload dist for APK content job
+ uses: actions/upload-artifact@v4
+ with:
+ name: site-dist
+ path: docs/.vitepress/dist
+ retention-days: 1
+
# Step 5: Save your files back to the branch only when deployment wraps up completely
- name: Commit generated changelog to repo
run: |
@@ -137,7 +147,70 @@ jobs:
echo "No changes"
fi
- # Job 3: Clean deployment production pipeline
+ # Job 3: Publish the site content bundle the offline APK's
+ # in-app updater checks for — reuses build's output, no rebuild.
+ # This used to be its own workflow (update-apk-content.yml) that
+ # ran docs:build a second time; folded in here so the site only
+ # gets built once per push, and so this always runs after build's
+ # changelog commit rather than racing it.
+ apk-content:
+ runs-on: ubuntu-latest
+ if: github.actor != 'bot-for-notamitgamer[bot]'
+ needs: build
+ permissions:
+ contents: write
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v7
+ with:
+ fetch-depth: 1
+
+ - name: Download built site
+ uses: actions/download-artifact@v4
+ with:
+ name: site-dist
+ path: dist
+
+ - name: Package content bundle
+ id: bundle
+ run: |
+ cd dist
+ zip -qr ../bundle.zip .
+ cd ..
+ echo "checksum=$(sha256sum bundle.zip | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
+ echo "version=${{ github.run_number }}" >> "$GITHUB_OUTPUT"
+
+ # Reuses the same 'apk-content' release across runs — each push
+ # just replaces the bundle.zip asset in place.
+ - name: Publish content bundle to release
+ uses: softprops/action-gh-release@v2
+ with:
+ tag_name: apk-content
+ name: APK content bundle (latest)
+ body: |
+ Latest site content bundle for the offline app's auto-updater.
+ Not a standalone release — this backs apk-manifest/manifest.json.
+ files: bundle.zip
+ prerelease: true
+
+ - name: Commit updated manifest to repo
+ run: |
+ mkdir -p apk-manifest
+ cat > apk-manifest/manifest.json <<EOF
+ {
+ "version": "${{ steps.bundle.outputs.version }}",
+ "url": "https://github.com/${{ github.repository }}/releases/download/apk-content/bundle.zip",
+ "checksum": "${{ steps.bundle.outputs.checksum }}",
+ "built_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
+ }
+ EOF
+
+ git config user.name "bot-for-notamitgame[bot]"
+ git config user.email "bot-for-notamitgamer[bot]@://github.com"
+ git add apk-manifest/manifest.json
+ git diff --cached --quiet && echo "No manifest changes" || (git commit -m "chore: update APK content manifest [skip ci]" && git push origin HEAD:main)
+
+ # Job 4: Clean deployment production pipeline
deploy:
environment:
name: github-pages
diff --git a/.github/workflows/update-apk-content.yml b/.github/workflows/update-apk-content.yml
@@ -1,98 +0,0 @@
-name: Update APK Content
-
-# The cheap counterpart to build-apk.yml. Runs on every push to main —
-# no Android SDK, no Gradle, just the normal site build plus a zip and
-# a small commit. This is what makes per-push updates affordable: the
-# installed app's shell never rebuilds, it just downloads this new
-# content bundle next time it's online and notices the version changed.
-#
-# paths-ignore excludes apk-manifest/manifest.json since this workflow
-# writes that file itself — without the exclusion, every run would
-# trigger another run in an infinite loop.
-on:
- push:
- branches:
- - main
- paths-ignore:
- - 'CHANGELOG.md'
- - 'apk-manifest/manifest.json'
- workflow_dispatch:
-
-permissions:
- contents: write
-
-jobs:
- update-content:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Setup Node
- uses: actions/setup-node@v4
- with:
- node-version: 20
- cache: 'npm'
-
- - name: Install site deps
- run: npm ci
-
- # main.yml runs these before the VitePress build — they generate
- # the per-folder index.md files (practice/index.md, etc.) that
- # the rest of the docs link to. Skipping them is what caused the
- # "16 dead link(s) found" build failure.
- - name: Setup Python
- uses: actions/setup-python@v5
- with:
- python-version: '3.13'
-
- - name: Generate markdown files
- run: |
- python list.py
- python main.py
-
- - name: Build VitePress site
- run: npm run docs:build
-
- - name: Package content bundle
- id: bundle
- run: |
- cd docs/.vitepress/dist
- zip -qr ../../../bundle.zip .
- cd ../../..
- echo "checksum=$(sha256sum bundle.zip | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
- echo "version=${{ github.run_number }}" >> "$GITHUB_OUTPUT"
-
- # Reuses the same 'apk-content' release across runs — each push
- # just replaces the bundle.zip asset in place, it doesn't create
- # a new release every time.
- - name: Publish content bundle to release
- uses: softprops/action-gh-release@v2
- with:
- tag_name: apk-content
- name: APK content bundle (latest)
- body: |
- Latest site content bundle for the offline app's auto-updater.
- Not a standalone release — this backs apk-manifest/manifest.json.
- files: bundle.zip
- prerelease: true
-
- - name: Commit updated manifest to repo
- env:
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- mkdir -p apk-manifest
- cat > apk-manifest/manifest.json <<EOF
- {
- "version": "${{ steps.bundle.outputs.version }}",
- "url": "https://github.com/${{ github.repository }}/releases/download/apk-content/bundle.zip",
- "checksum": "${{ steps.bundle.outputs.checksum }}",
- "built_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
- }
- EOF
-
- git config user.name "github-actions[bot]"
- git config user.email "github-actions[bot]@users.noreply.github.com"
- git add apk-manifest/manifest.json
- git diff --cached --quiet && echo "No manifest changes" || git commit -m "chore: update APK content manifest (run ${{ github.run_number }})"
- git push origin HEAD:main