The native Kotlin/Compose app is replaced by a Capacitor shell that loads the existing Svelte web app from the self-hosted server URL, set via APP_SERVER_URL secret at build time. - web/capacitor.config.ts: appId com.danvics.calorieai, reads APP_SERVER_URL env var so the WebView points at the live server - web/android/: Capacitor-generated Android project (gradlew included) - AndroidManifest.xml: added CAMERA, READ_MEDIA_IMAGES, READ_EXTERNAL_STORAGE - MealForm.svelte: split file input into Camera (capture=environment) and Gallery buttons so both options are accessible natively - release.yml: npm ci → npm run build → cap sync → gradlew assembleDebug; removed manual Gradle installation, uses bundled gradlew instead - package.json: Capacitor packages as devDependencies (not shipped in the Docker server image) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
66 lines
2.8 KiB
YAML
66 lines
2.8 KiB
YAML
name: Android Release
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
release-apk:
|
|
runs-on: android-ci
|
|
steps:
|
|
- name: Check out repository
|
|
run: |
|
|
git clone "http://forgejo:3000/${GITHUB_REPOSITORY}.git" .
|
|
git checkout "$GITHUB_SHA"
|
|
|
|
- name: Install tools
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y --no-install-recommends ca-certificates curl nodejs npm unzip
|
|
|
|
- name: Build web app and sync Capacitor
|
|
env:
|
|
APP_SERVER_URL: ${{ secrets.APP_SERVER_URL }}
|
|
run: |
|
|
cd web
|
|
npm ci
|
|
npm run build
|
|
npx cap sync android
|
|
|
|
- name: Build APK
|
|
run: |
|
|
cd web/android
|
|
chmod +x gradlew
|
|
./gradlew --no-daemon assembleDebug
|
|
mkdir -p ../../dist
|
|
cp app/build/outputs/apk/debug/*.apk "../../dist/calorie-ai-${GITHUB_REF_NAME}.apk"
|
|
|
|
- name: Publish Forgejo release asset
|
|
env:
|
|
FORGEJO_API: http://forgejo:3000/api/v1
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
apk="dist/calorie-ai-${GITHUB_REF_NAME}.apk"
|
|
auth_header="Authorization: token ${TOKEN}"
|
|
release_json="$(curl -fsS -H "$auth_header" "$FORGEJO_API/repos/${GITHUB_REPOSITORY}/releases/tags/${GITHUB_REF_NAME}" || true)"
|
|
if [ -z "$release_json" ]; then
|
|
release_json="$(node -e 'console.log(JSON.stringify({ tag_name: process.env.GITHUB_REF_NAME, name: `Calorie AI ${process.env.GITHUB_REF_NAME}`, body: "Capacitor Android APK for Calorie AI.", draft: false, prerelease: false }))' | curl -fsS -X POST -H "$auth_header" -H 'Content-Type: application/json' --data-binary @- "$FORGEJO_API/repos/${GITHUB_REPOSITORY}/releases")"
|
|
fi
|
|
release_id="$(printf '%s' "$release_json" | node -e 'let data=""; process.stdin.on("data", c => data += c); process.stdin.on("end", () => console.log(JSON.parse(data).id));')"
|
|
asset_id="$(printf '%s' "$release_json" | node -e 'let data=""; process.stdin.on("data", c => data += c); process.stdin.on("end", () => { const release = JSON.parse(data); const asset = (release.assets || []).find(item => item.name === \`calorie-ai-${process.env.GITHUB_REF_NAME}.apk\`); if (asset) console.log(asset.id); });')"
|
|
if [ -n "$asset_id" ]; then
|
|
curl -fsS -X DELETE -H "$auth_header" "$FORGEJO_API/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets/${asset_id}"
|
|
fi
|
|
curl -fsS -X POST -H "$auth_header" -F "attachment=@${apk}" "$FORGEJO_API/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets?name=calorie-ai-${GITHUB_REF_NAME}.apk"
|
|
|
|
- name: Upload APK artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: calorie-ai-apk
|
|
path: dist/*.apk
|