Skip to content

feat: Enhance MainViewModel with lifecycle awareness and reconnect logic #23

feat: Enhance MainViewModel with lifecycle awareness and reconnect logic

feat: Enhance MainViewModel with lifecycle awareness and reconnect logic #23

Workflow file for this run

name: Build and Release APK

Check failure on line 1 in .github/workflows/BuildApk.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/BuildApk.yaml

Invalid workflow file

(Line: 3, Col: 4): Unexpected value ''
run-name: ${{github.actor}} is building and releasing APK
on:
# push:
# branches:
# - main
# paths:
# - "client-mobile/**"
# - ".github/workflows/BuildApk.yaml"
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 🏗 Setup repo
uses: actions/checkout@v4
- name: 🏗 Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: npm
cache-dependency-path: client-mobile/package-lock.json
- name: 🏗 Setup EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: 📦 Install dependencies
run: |
cd client-mobile
npm install
- name: 🔧 Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: 🍭 Generate timestamp version
id: version
run: |
VERSION="v$(date +'%Y.%m.%d-%H%M%S')"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: 📥 Download existing release assets
id: download_existing
run: |
echo "🔍 Checking for existing release..."
LATEST_RELEASE=$(curl -s "https://api.github.com/repos/${{ github.repository }}/releases/latest" || echo "{}")
if [ "$(echo $LATEST_RELEASE | jq -r '.message')" != "Not Found" ]; then
echo "✅ Found existing release, downloading assets..."
mkdir -p ./existing-assets
echo $LATEST_RELEASE | jq -r '.assets[] | select(.name | contains("client-") or contains("server.py")) | .browser_download_url' | while read url; do
if [ -n "$url" ]; then
echo "📥 Downloading: $(basename $url)"
curl -L -o "./existing-assets/$(basename $url)" "$url"
fi
done
echo "existing_files=true" >> $GITHUB_OUTPUT
else
echo "ℹ️ No existing release found"
echo "existing_files=false" >> $GITHUB_OUTPUT
fi
- name: 🚀 Build app and get download URL
run: |
cd client-mobile
echo "=== Building app with JSON output ==="
eas build --platform android --profile production --non-interactive --json > build_output.json
echo "=== Build output ==="
cat build_output.json
BUILD_URL=$(jq -r '.[0].artifacts.buildUrl' build_output.json)
if [ "$BUILD_URL" != "null" ] && [ -n "$BUILD_URL" ]; then
echo "✅ Found build URL: $BUILD_URL"
echo "BUILD_URL=$BUILD_URL" >> $GITHUB_ENV
else
echo "❌ No build URL found in output"
exit 1
fi
- name: 📥 Download APK
run: |
echo "=== Downloading APK ==="
echo "Build URL: $BUILD_URL"
curl -L -o client-${{ steps.version.outputs.version }}-android.apk "$BUILD_URL"
echo "✅ Downloaded APK successfully"
if [ -f client-${{ steps.version.outputs.version }}-android.apk ]; then
echo "✅ APK file size: $(ls -lh client-${{ steps.version.outputs.version }}-android.apk | awk '{print $5}')"
else
echo "❌ APK download failed"
exit 1
fi
- name: 🍩 Prepare release files
run: |
mkdir -p ./release
if [ "${{ steps.download_existing.outputs.existing_files }}" == "true" ]; then
cp -r ./existing-assets/* ./release/ 2>/dev/null || true
fi
if [ -f client-${{ steps.version.outputs.version }}-android.apk ]; then
echo "📱 Copying APK to release directory..."
cp client-${{ steps.version.outputs.version }}-android.apk ./release/
echo "✅ APK copied successfully"
else
echo "❌ APK file not found: client-${{ steps.version.outputs.version }}-android.apk"
ls -la client-*.apk 2>/dev/null || echo "No APK files found"
fi
find ./release -name "client-v*.apk" ! -name "client-${{ steps.version.outputs.version }}-android.apk" -delete 2>/dev/null || true
echo "=== Final release files ==="
ls -la ./release/
- name: 🍆 Create Release and Upload Assets
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.version }}
name: Release ${{ steps.version.outputs.version }}
body: |
🚀 **Multi-Platform Release**
Automatically built and released from commit ${{ github.sha }}
## 📋 Server Setup
1. Clone repository and deploy `server.py` on your server
3. Run `python server.py`
4. Server will listen on port 12345 by default
## 💻 Desktop Clients
1. Download the appropriate client for your OS
2. Run the executable
3. If server and client are on same device, use `127.0.0.1` as server address
## 📱 Mobile App (Android)
1. Download the APK file
2. Enable "Install from unknown sources" in Android settings
3. Install the APK on your device
4. Configure server address in the app
## 📦 Available Downloads
- **Windows Desktop**: `client-${{ steps.version.outputs.version }}-windows.exe`
- **Linux Desktop**: `client-${{ steps.version.outputs.version }}-ubuntu`
- **Android Mobile**: `client-${{ steps.version.outputs.version }}-android.apk`
- **Server**: Clone repository for `server.py`
files: ./release/*
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}