Merge pull request #14 from skywinder/updates #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Android APK | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| build-android: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| cache-dependency-path: friend-lite/package-lock.json | |
| - name: Setup Expo CLI | |
| run: npm install -g @expo/cli eas-cli | |
| - name: Install dependencies | |
| working-directory: ./friend-lite | |
| run: npm ci | |
| - name: Create EAS configuration | |
| working-directory: ./friend-lite | |
| run: | | |
| if [ ! -f eas.json ]; then | |
| echo "Creating eas.json configuration..." | |
| cat > eas.json << 'EOF' | |
| { | |
| "cli": { | |
| "version": ">= 12.0.0" | |
| }, | |
| "build": { | |
| "development": { | |
| "developmentClient": true, | |
| "distribution": "internal" | |
| }, | |
| "preview": { | |
| "distribution": "internal", | |
| "android": { | |
| "buildType": "apk" | |
| } | |
| }, | |
| "production": { | |
| "android": { | |
| "buildType": "apk" | |
| } | |
| } | |
| }, | |
| "submit": { | |
| "production": {} | |
| } | |
| } | |
| EOF | |
| else | |
| echo "eas.json already exists" | |
| fi | |
| - name: Prebuild Android project | |
| working-directory: ./friend-lite | |
| run: | | |
| echo "Running expo prebuild to generate native android code..." | |
| npx expo prebuild --platform android --clear | |
| - name: Setup Java 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Create debug keystore | |
| working-directory: ./friend-lite/android/app | |
| run: | | |
| if [ ! -f debug.keystore ]; then | |
| echo "Creating debug keystore..." | |
| keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug,O=Android,C=US" | |
| else | |
| echo "Debug keystore already exists, skipping creation" | |
| fi | |
| - name: Make gradlew executable | |
| working-directory: ./friend-lite/android | |
| run: chmod +x ./gradlew | |
| - name: Build APK | |
| working-directory: ./friend-lite/android | |
| run: ./gradlew assembleRelease | |
| - name: Upload APK artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: friend-lite-release-apk | |
| path: friend-lite/android/app/build/outputs/apk/release/app-release.apk | |
| retention-days: 30 | |
| - name: Upload APK to release (if main branch) | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: friend-lite-main-release-${{ github.sha }} | |
| path: friend-lite/android/app/build/outputs/apk/release/app-release.apk | |
| retention-days: 90 |