Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Store releases: Android build script for the APK and the Play bundle, iOS finishing on Linux, docs/APP_STORES.md

Duarte Santos1ec80c403340
diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml
index 2c019be92..40334f7de 100644
--- a/.github/workflows/ios.yml
+++ b/.github/workflows/ios.yml
@@ -112,7 +112,7 @@ jobs:
# The web assets are put back on the release machine; leave the repo's out of the zip.
rm -rf App.app/public/exercise-media
mkdir -p ../../../Payload && cp -R App.app ../../../Payload/
- cd ../../.. && zip -qry App-unsigned.ipa Payload
+ cd ../../.. && echo "$GITHUB_SHA" > ci-commit.txt && zip -qry App-unsigned.ipa Payload ci-commit.txt
ls -la App-unsigned.ipa
- uses: actions/upload-artifact@v6
with:
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b675de473..2eece3403 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -503,7 +503,8 @@ build:web-check:
# The official signed APK. Signing keys live in protected CI variables, so they only
# exist on protected refs (main and v* tags) — a fork's MR builds an unsigned APK and
-# cannot get at the key. Sideload-only by design: openGym is on no app store.
+# cannot get at the key. This is the sideloaded APK; the store builds are made on the release
+# machine (docs/APP_STORES.md).
#
# Needs three CI/CD variables (Settings → CI/CD → Variables), all *protected*:
# ANDROID_KEYSTORE_B64 file base64 of opengym-release.keystore
@@ -538,8 +539,10 @@ build:apk:
npm run build:mobile
VER="$(node -p "require('./package.json').version")"
cd android
- ./gradlew --no-daemon assembleRelease
- UNSIGNED=app/build/outputs/apk/release/app-release-unsigned.apk
+ # The sideload flavour: the APK that updates itself (the play flavour is the Google Play
+ # build, built and signed on the release machine as an .aab, docs/APP_STORES.md).
+ ./gradlew --no-daemon assembleSideloadRelease
+ UNSIGNED=app/build/outputs/apk/sideload/release/app-sideload-release-unsigned.apk
BT="$(ls -d "$ANDROID_HOME"/build-tools/* | sort -V | tail -1)"
if [ -n "${ANDROID_KEYSTORE_B64:-}" ]; then
base64 -d "$ANDROID_KEYSTORE_B64" > "$CI_PROJECT_DIR/.ks.jks"
diff --git a/docs/APP_STORES.md b/docs/APP_STORES.md
new file mode 100644
index 000000000..afcd65914
--- /dev/null
+++ b/docs/APP_STORES.md
@@ -0,0 +1,119 @@
+# openGym in Google Play and the App Store
+
+openGym ships to phones three ways, all from the same code and the same version number:
+
+| | Where | Who installs updates | Built where |
+|---|---|---|---|
+| Android APK | GitHub release, opengym.ch | the app itself (Settings → About) | release machine |
+| Android, Google Play | Play Store | Google Play | release machine |
+| iPhone | App Store | the App Store | Mac runner (compile) + release machine (finish, sign) |
+
+The two Android builds are flavours of one Gradle project (`frontend/android/app/build.gradle`):
+`sideload` keeps the updater (InstallPlugin, `REQUEST_INSTALL_PACKAGES`), `play` leaves both out,
+since Google Play does not allow an app to update itself. Same application id, same key, so a
+phone can move from the APK to Play without losing its data. The page asks which build it runs in
+(`ChannelPlugin`, `lib/channel.js`) and shows the update row only in the APK.
+
+**Why the release machine:** the full-quality exercise animations may only ever be inside the
+app package itself (Gym visual licence, Part B), never in a repository, a CI run or a file anyone
+can download. So the store packages are put together and signed locally, like the APK. CI only
+ever sees the repo's 180 px media.
+
+## Requirements the builds meet
+
+- **Google Play:** targets Android 16 (API 36), required for new apps and updates since
+ 31 August 2026 (Capacitor 8). Native libraries are 16 KB page aligned. The bundle is about
+ 290 MB, under Play's 500 MB limit for the base module, so the animations stay in the base
+ module and no asset packs are needed.
+- **App Store:** built with Xcode 26 (the `macos-26` runner). Privacy manifest
+ (`ios/App/App/PrivacyInfo.xcprivacy`): no tracking, no data collected. No non-exempt
+ encryption (`ITSAppUsesNonExemptEncryption = NO`, HTTPS only). The Coach asks before anything
+ is sent to an AI provider and names it (App Review Guideline 5.1.2(i), November 2025).
+- **Both:** no account, no ads, no analytics in the app. Donations are only linked from the
+ website, never from inside the app: both stores require their own payment system for that.
+
+## Every release
+
+Bump the version in the usual places, plus the iPhone app's
+`MARKETING_VERSION` (= `versionName`) and `CURRENT_PROJECT_VERSION` (= `versionCode`) in
+`frontend/ios/App/App.xcodeproj/project.pbxproj`.
+
+### Android
+
+```sh
+cd gym-app # the release checkout, at the release tag
+export ANDROID_HOME=/opt/android-sdk
+K=/root/.config/opengym
+scripts/android/build-release.sh $K/opengym-release.keystore $K/keystore.pass $K/key.alias ~/release
+# → openGym-X.Y.Z.apk (+ .sha256) for the GitHub release, openGym-X.Y.Z.aab for Google Play
+```
+
+Upload the `.aab` in Play Console → Test and release → Production (or a testing track first),
+with the release notes from the changelog.
+
+### iPhone
+
+1. Push the tag; the `iOS` workflow (`.github/workflows/ios.yml`) builds `ios-unsigned-ipa` for it.
+ Download that artifact (`gh run download <run> -n ios-unsigned-ipa`).
+2. Build the phone bundle with the app's animations, from the same commit:
+ `cd frontend && VITE_CLIP_EXT=webp APP_MEDIA_DIR=/mnt/backup-hdd/opengym-media/build-appwebp npm run build:mobile`
+3. Finish and sign it:
+ `scripts/ios/finish-ipa.sh App-unsigned.ipa dist.p12 dist.pass openGym_AppStore.mobileprovision`
+ It refuses an IPA from another commit or a bundle without the animations.
+4. Upload: `iTMSTransporter -m upload -assetFile openGym-X.Y.Z.ipa -apiKey <KEY_ID> -apiIssuer <ISSUER_ID>`
+ (Apple's Transporter for Linux, with an App Store Connect API key in `~/.appstoreconnect/private_keys/`).
+ The build shows up in TestFlight after Apple's processing; submit it for review from there.
+
+## One-time setup (owner)
+
+### Google Play
+
+1. Play Console developer account (25 USD once, identity check). A new *personal* account must
+ run a closed test with at least 12 testers for 14 days in a row before it can publish to
+ production; the Discord community is the obvious tester pool. An *organisation* account
+ (needs a D-U-N-S number) skips that.
+2. Create the app: name openGym, default language English, free, no ads.
+3. **App signing:** choose to use your own key ("Use existing app signing key", Play's PEPK
+ tool exports it encrypted). Then Play signs with the same key as the APK and people can
+ switch from the APK to Play keeping their data. With a key Google generates, the two are
+ separate apps on a phone. This cannot be changed later.
+4. Store listing, content rating questionnaire (no violence, no user content shared with
+ others: "Everyone"), target audience 13+ or 16+, Data safety (below).
+5. Declarations Play asks for:
+ - **Health Connect** (write exercise, write weight): the in-app reason screen exists; the
+ form asks what the data is used for: "writes finished workouts and weigh-ins, reads nothing".
+ - **Foreground service, special use:** the rest countdown in the notification shade
+ (`RestTimerService`). Play may ask for a short screen recording of a rest running.
+ - **Exact alarms:** only the user-granted `SCHEDULE_EXACT_ALARM` (reminder to the minute),
+ no `USE_EXACT_ALARM`.
+ - **Camera:** scanning the gym membership code and photos of your own exercises.
+
+**Data safety answers:** no data collected, no data shared. Data stays on the device; the
+optional sync goes to a server the user runs or picks themselves (not the developer's), and
+the optional Coach sends training data straight from the phone to the AI provider the user
+chose, with the user's own key, after asking. Encryption in transit: yes. Deletion: the data is
+on the phone (Settings → Reset, or uninstall).
+
+### App Store
+
+1. Apple Developer Program (99 USD a year, as an individual; the seller name shown is your
+ legal name).
+2. App Store Connect → new app, bundle id `ch.duartesantos.opengym`. If "openGym" is taken as an
+ App Store name, "openGym: Workout Tracker" keeps the brand.
+3. Signing material, all doable from Linux:
+ - `openssl req -new -newkey rsa:2048 -nodes -keyout dist.key -out dist.csr -subj "/CN=Duarte Santos/emailAddress=…"`,
+ upload the CSR under Certificates → Apple Distribution, download `distribution.cer`, then
+ `openssl x509 -inform der -in distribution.cer -out dist.pem && openssl pkcs12 -export -legacy -inkey dist.key -in dist.pem -out dist.p12`.
+ - Profiles → App Store Connect profile for `ch.duartesantos.opengym` → `openGym_AppStore.mobileprovision`.
+ - Users and Access → Integrations → App Store Connect API key (App Manager) for uploads.
+ - Keep all of it next to the Android keystore (`/root/.config/opengym/`, never in a repo).
+4. App Privacy: "Data Not Collected". Age rating: 4+. Category: Health & Fitness.
+5. Review notes: no sign-in needed ("Use on this device"). The Coach is optional and needs the
+ user's own AI provider key; give the reviewer a key with a small spending limit, or say so.
+
+## Licensing
+
+The repository's `NOTICE.md` carries an app-store exception to the AGPL (an additional
+permission under AGPL §7, since July 2026). The Contributor License Agreement in preparation
+covers the rest: it lets the project keep publishing and updating the store apps long term,
+contributions included.
diff --git a/docs/MOBILE.md b/docs/MOBILE.md
index 0f6bf9735..6d2c80012 100644
--- a/docs/MOBILE.md
+++ b/docs/MOBILE.md
@@ -278,7 +278,7 @@ Android asks you to allow installs from the browser the first time — that's st
app outside the Play Store. Check the `.sha256` if you got the file from anywhere else.
Both come out of CI: the `build:apk` job in [`.gitlab-ci.yml`](../.gitlab-ci.yml) runs
-`npm run build:mobile` and `./gradlew assembleRelease`, then `zipalign`s and signs the result
+`npm run build:mobile` and `./gradlew assembleSideloadRelease`, then `zipalign`s and signs the result
with the release key. The job runs on every push to `main` too, so the newest unreleased
build is always one click away (signed with the same key, installs over a release):
`https://gitlab.com/DuarteSantos8/opengym/-/jobs/artifacts/main/browse?job=build:apk`
@@ -297,19 +297,21 @@ To build and sign your own:
```sh
cd frontend && npm run build:mobile
-cd android && ./gradlew assembleRelease # → app/build/outputs/apk/release/app-release-unsigned.apk
+cd android && ./gradlew assembleSideloadRelease # → app/build/outputs/apk/sideload/release/app-sideload-release-unsigned.apk
# one-time: create a keystore. KEEP IT — updates must be signed with the same key,
# or Android refuses to install the new version over the old one.
keytool -genkeypair -keystore my.keystore -alias opengym -keyalg RSA -validity 10950
# align + sign (zipalign/apksigner ship with the Android SDK build-tools)
-zipalign -f -p 4 app-release-unsigned.apk aligned.apk
+zipalign -f -p 4 app-sideload-release-unsigned.apk aligned.apk
apksigner sign --ks my.keystore --ks-key-alias opengym --out openGym.apk aligned.apk
```
### iPhone — what's actually possible
+> The App Store and Google Play builds, and how a release gets there: [APP_STORES.md](APP_STORES.md).
+
Apple does not allow installing apps outside the App Store, so there is no `.ipa` download
that would simply install. Your free options:
diff --git a/scripts/android/build-release.sh b/scripts/android/build-release.sh
new file mode 100755
index 000000000..a54350425
--- /dev/null
+++ b/scripts/android/build-release.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+# Builds and signs both Android releases on the release machine, from one phone build:
+# openGym-<version>.apk the sideloaded APK (GitHub, opengym.ch): updates itself
+# openGym-<version>.aab the Google Play bundle: Play updates it
+# The full-quality animations go into both packages and nowhere else (Gym visual licence,
+# Part B), which is why this runs here and not in CI. Same key for both: a phone can move from
+# the APK to Google Play and keep its data, as long as Play App Signing uses this key too
+# (docs/APP_STORES.md).
+#
+# Usage: scripts/android/build-release.sh <keystore> <password-file> <alias-file> [out-dir]
+# APP_MEDIA_DIR defaults to /mnt/backup-hdd/opengym-media/build-appwebp.
+set -euo pipefail
+
+KS=${1:?keystore}; PASS=${2:?file with the keystore password}; ALIAS=$(cat "${3:?file with the key alias}")
+ROOT=$(cd "$(dirname "$0")/../.." && pwd)
+OUT=${4:-$PWD}
+export APP_MEDIA_DIR=${APP_MEDIA_DIR:-/mnt/backup-hdd/opengym-media/build-appwebp}
+export VITE_CLIP_EXT=webp
+: "${ANDROID_HOME:?set ANDROID_HOME}"
+BT=$(ls -d "$ANDROID_HOME"/build-tools/* | sort -V | tail -1)
+
+cd "$ROOT/frontend"
+VER=$(node -p "require('./package.json').version")
+GRADLE_VER=$(sed -n 's/.*versionName "\(.*\)"/\1/p' android/app/build.gradle)
+[ "$VER" = "$GRADLE_VER" ] || { echo "package.json says $VER, build.gradle says $GRADLE_VER" >&2; exit 1; }
+
+npm run build:mobile
+(cd android && ./gradlew --no-daemon clean assembleSideloadRelease bundlePlayRelease)
+
+APK_IN=android/app/build/outputs/apk/sideload/release/app-sideload-release-unsigned.apk
+AAB_IN=android/app/build/outputs/bundle/playRelease/app-play-release.aab
+
+"$BT/zipalign" -f -p 4 "$APK_IN" "$OUT/aligned.apk"
+"$BT/apksigner" sign --ks "$KS" --ks-pass "file:$PASS" --ks-key-alias "$ALIAS" \
+ --out "$OUT/openGym-$VER.apk" "$OUT/aligned.apk"
+rm -f "$OUT/aligned.apk" "$OUT/openGym-$VER.apk.idsig"
+"$BT/apksigner" verify --print-certs "$OUT/openGym-$VER.apk" | grep -i "SHA-256"
+(cd "$OUT" && sha256sum "openGym-$VER.apk" > "openGym-$VER.apk.sha256")
+
+# An app bundle is signed like a jar; Play checks it with the upload key and re-signs the APKs
+# it builds from it with the app signing key.
+cp "$AAB_IN" "$OUT/openGym-$VER.aab"
+jarsigner -keystore "$KS" -storepass:file "$PASS" -keypass:file "$PASS" \
+ -sigalg SHA256withRSA -digestalg SHA-256 "$OUT/openGym-$VER.aab" "$ALIAS" >/dev/null
+jarsigner -verify "$OUT/openGym-$VER.aab" | grep -q "jar verified" || { echo "the bundle did not verify" >&2; exit 1; }
+
+ls -la "$OUT/openGym-$VER.apk" "$OUT/openGym-$VER.aab"
diff --git a/scripts/ios/finish-ipa.sh b/scripts/ios/finish-ipa.sh
new file mode 100755
index 000000000..ea67c0c8f
--- /dev/null
+++ b/scripts/ios/finish-ipa.sh
@@ -0,0 +1,70 @@
+#!/usr/bin/env bash
+# Finishes the App Store build of the iPhone app on the release machine.
+#
+# The Mac runner (.github/workflows/ios.yml, job device-archive) compiles the app and leaves an
+# unsigned IPA without its web assets. The full-quality exercise animations may only ever be
+# inside the app package itself (Gym visual licence, Part B), never in a repo, a CI run or a file
+# anyone can download, so they are put in here, on this machine, from the phone build in
+# frontend/ios/App/App/public, and the result is signed with the App Store distribution
+# certificate. No Mac needed: rcodesign signs on Linux.
+#
+# Usage:
+# scripts/ios/finish-ipa.sh <App-unsigned.ipa> <dist.p12> <p12-password-file> <profile.mobileprovision> [out.ipa]
+#
+# Before: the phone build with the app's animations, from the same commit as the IPA:
+# cd frontend && VITE_CLIP_EXT=webp APP_MEDIA_DIR=/mnt/backup-hdd/opengym-media/build-appwebp npm run build:mobile
+# After: upload the IPA (docs/APP_STORES.md, "Upload").
+set -euo pipefail
+
+IPA=${1:?unsigned IPA}; P12=${2:?distribution .p12}; P12PASS=${3:?file with the .p12 password}
+PROFILE=${4:?App Store provisioning profile}
+ROOT=$(cd "$(dirname "$0")/../.." && pwd)
+FRONT="$ROOT/frontend"
+VERSION=$(node -p "require('$FRONT/package.json').version")
+OUT=${5:-"$PWD/openGym-$VERSION.ipa"}
+RCODESIGN=${RCODESIGN:-rcodesign}
+WORK=$(mktemp -d "${TMPDIR:-/tmp}/finish-ipa.XXXXXX")
+trap 'rm -rf "$WORK"' EXIT
+
+PUBLIC="$FRONT/ios/App/App/public"
+[ -f "$PUBLIC/index.html" ] || { echo "no phone build in $PUBLIC: run npm run build:mobile first" >&2; exit 1; }
+grep -q 'name="opengym-flavor" content="mobile"' "$PUBLIC/index.html" || { echo "$PUBLIC is not the phone build" >&2; exit 1; }
+CLIPS=$(find "$PUBLIC/exercise-media" -name '*.webp' 2>/dev/null | wc -l)
+[ "$CLIPS" -gt 6000 ] || { echo "$PUBLIC has $CLIPS WebP animations: build with VITE_CLIP_EXT=webp and APP_MEDIA_DIR" >&2; exit 1; }
+
+unzip -q "$IPA" -d "$WORK/ipa"
+APP="$WORK/ipa/Payload/App.app"
+[ -d "$APP" ] || { echo "$IPA has no Payload/App.app" >&2; exit 1; }
+
+# The IPA and the web build must come from the same commit: the native side and the page talk
+# through plugins that change together.
+if [ -f "$WORK/ipa/ci-commit.txt" ]; then
+ CI_SHA=$(cat "$WORK/ipa/ci-commit.txt"); HERE=$(git -C "$ROOT" rev-parse HEAD)
+ [ "$CI_SHA" = "$HERE" ] || { echo "the IPA is from $CI_SHA, this checkout is $HERE" >&2; exit 1; }
+ rm "$WORK/ipa/ci-commit.txt"
+fi
+PLIST_VERSION=$(python3 -c "import plistlib,sys;print(plistlib.load(open(sys.argv[1],'rb'))['CFBundleShortVersionString'])" "$APP/Info.plist")
+[ "$PLIST_VERSION" = "$VERSION" ] || { echo "the IPA says $PLIST_VERSION, package.json says $VERSION" >&2; exit 1; }
+
+rm -rf "$APP/public"
+cp -R "$PUBLIC" "$APP/public"
+cp "$FRONT/ios/App/App/capacitor.config.json" "$APP/capacitor.config.json"
+cp "$PROFILE" "$APP/embedded.mobileprovision"
+
+# The entitlements are the profile's own (application identifier, team), never a debug build's.
+openssl smime -inform der -verify -noverify -in "$PROFILE" -out "$WORK/profile.plist" 2>/dev/null
+python3 - "$WORK/profile.plist" "$WORK/entitlements.plist" <<'PY'
+import plistlib, sys
+p = plistlib.load(open(sys.argv[1], 'rb'))
+e = dict(p['Entitlements'])
+e['get-task-allow'] = False
+assert e['application-identifier'].endswith('.ch.duartesantos.opengym'), e['application-identifier']
+plistlib.dump(e, open(sys.argv[2], 'wb'))
+print('profile:', p['Name'], '| team', p['TeamIdentifier'][0], '| expires', p['ExpirationDate'])
+PY
+
+"$RCODESIGN" sign --p12-file "$P12" --p12-password-file "$P12PASS" \
+ --entitlements-xml-file "App:$WORK/entitlements.plist" "$APP"
+
+(cd "$WORK/ipa" && rm -f "$OUT" && python3 -m zipfile -c "$OUT" Payload)
+echo "signed: $OUT ($(du -h "$OUT" | cut -f1), $CLIPS animations)"