165 lines
4.0 KiB
Markdown
165 lines
4.0 KiB
Markdown
# Push Updates
|
|
|
|
Use this when pushing code from the Mac to `git.whoagland.com`, then updating the TrueNAS-hosted server.
|
|
|
|
## Rules
|
|
|
|
- Git deploys code only.
|
|
- TrueNAS save data lives in `/mnt/usbssds/apps/iwanttoheal/data/game.db`.
|
|
- Do not commit, copy, or replace `data/game.db`.
|
|
- Do not run character reset commands unless you intentionally want a wipe.
|
|
- Restarting the TrueNAS app runs `npm ci`, `npm run db:init`, `npm run build`, and `npm start`.
|
|
|
|
## Step 1: Build Web Locally
|
|
|
|
```sh
|
|
cd /Users/warren/Documents/testgame/testgame
|
|
npm run build
|
|
```
|
|
|
|
This validates TypeScript, builds the browser app, and refreshes `src/offline-starter-profile.json`.
|
|
|
|
## Step 2: Optional Android APK
|
|
|
|
Only run this when building a new APK.
|
|
|
|
```sh
|
|
set -e
|
|
|
|
cd /Users/warren/Documents/testgame/testgame
|
|
|
|
export JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"
|
|
export PATH="$JAVA_HOME/bin:$PATH"
|
|
|
|
VERSION="1.0.27"
|
|
|
|
CURRENT_CODE=$(grep -E 'versionCode [0-9]+' android/app/build.gradle | awk '{print $2}')
|
|
NEXT_CODE=$((CURRENT_CODE + 1))
|
|
|
|
perl -0pi -e "s/versionCode\s+\d+/versionCode $NEXT_CODE/" android/app/build.gradle
|
|
perl -0pi -e "s/versionName\s+\"[^\"]+\"/versionName \"$VERSION\"/" android/app/build.gradle
|
|
|
|
VITE_API_BASE_URL="https://iwanttoheal.phenomrom.com" npm run android:sync
|
|
|
|
cd android
|
|
./gradlew clean assembleDebug
|
|
cd ..
|
|
|
|
cp android/app/build/outputs/apk/debug/app-debug.apk "IWantToHeal-Thor-v$VERSION.apk"
|
|
ls -lh "IWantToHeal-Thor-v$VERSION.apk"
|
|
```
|
|
|
|
## Step 3: Commit And Push Code
|
|
|
|
```sh
|
|
cd /Users/warren/Documents/testgame/testgame
|
|
|
|
git add .
|
|
git commit -m "Update game 1.0.27"
|
|
git push origin main
|
|
```
|
|
|
|
Check before committing:
|
|
|
|
```sh
|
|
git status --short
|
|
```
|
|
|
|
Expected: source/doc/build-output changes only. Do not stage `data/game.db`.
|
|
|
|
## Step 4: Optional Gitea Release For APK
|
|
|
|
Only run this when Step 2 created a new APK.
|
|
|
|
```sh
|
|
set -e
|
|
|
|
cd /Users/warren/Documents/testgame/testgame
|
|
|
|
export GITEA_URL="https://git.whoagland.com"
|
|
export GITEA_OWNER="phenom"
|
|
export GITEA_REPO="i-want-to-heal"
|
|
export GITEA_TOKEN="PASTE_TOKEN_HERE"
|
|
|
|
VERSION="1.0.26"
|
|
APK="IWantToHeal-Thor-v$VERSION.apk"
|
|
|
|
RELEASE_JSON=$(curl -sS -X POST "$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/releases" \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"v$VERSION\",\"target_commitish\":\"main\",\"name\":\"v$VERSION\",\"body\":\"I Want to Heal Android build v$VERSION\",\"draft\":false,\"prerelease\":false}")
|
|
|
|
RELEASE_ID=$(python3 -c 'import sys,json; data=json.load(sys.stdin); print(data.get("id") or data)' <<< "$RELEASE_JSON")
|
|
|
|
curl -sS -X POST "$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/releases/$RELEASE_ID/assets?name=$APK" \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-F "attachment=@$APK"
|
|
```
|
|
|
|
## Step 5: Update TrueNAS
|
|
|
|
```sh
|
|
cd /mnt/usbssds/apps/iwanttoheal/app
|
|
git pull
|
|
```
|
|
|
|
Before restarting, make a DB backup:
|
|
|
|
```sh
|
|
cp /mnt/usbssds/apps/iwanttoheal/data/game.db \
|
|
"/mnt/usbssds/apps/iwanttoheal/data/game-before-update-$(date +%Y%m%d-%H%M%S).db"
|
|
```
|
|
|
|
Then restart the `iwanttoheal` app in the TrueNAS Apps UI.
|
|
|
|
## What Happens On Restart
|
|
|
|
The app command runs:
|
|
|
|
```sh
|
|
npm ci && npm run db:init && npm run build && npm start
|
|
```
|
|
|
|
That means:
|
|
|
|
- dependency changes apply
|
|
- schema changes apply
|
|
- seed/static-content updates apply
|
|
- browser files rebuild
|
|
- existing accounts and characters stay in `data/game.db`
|
|
|
|
`npm run db:init` should not wipe saves. Character wipes are separate manual reset operations.
|
|
|
|
## Resetting TrueNAS Characters
|
|
|
|
Only run a reset when intentionally starting everyone over.
|
|
|
|
Resetting the Mac database does not reset TrueNAS. TrueNAS has its own persistent DB at:
|
|
|
|
```text
|
|
/mnt/usbssds/apps/iwanttoheal/data/game.db
|
|
```
|
|
|
|
Back it up first, then run the reset command or reset SQL on TrueNAS.
|
|
|
|
## If Something Looks Wrong
|
|
|
|
Check the mounted DB path:
|
|
|
|
```sh
|
|
ls -lh /mnt/usbssds/apps/iwanttoheal/data/game.db
|
|
```
|
|
|
|
Check the latest code:
|
|
|
|
```sh
|
|
cd /mnt/usbssds/apps/iwanttoheal/app
|
|
git log --oneline -5
|
|
```
|
|
|
|
Check the app API:
|
|
|
|
```sh
|
|
curl http://127.0.0.1:4173/api/auth/session
|
|
```
|