test workflow #3
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 Java 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Debug - Check directory structure | |
| run: | | |
| echo "Current directory:" | |
| pwd | |
| echo "Contents of current directory:" | |
| ls -la | |
| echo "Contents of friend-lite directory:" | |
| ls -la friend-lite/ || echo "friend-lite directory not found" | |
| echo "Contents of friend-lite/android directory:" | |
| ls -la friend-lite/android/ || echo "friend-lite/android directory not found" | |
| - name: Install dependencies | |
| working-directory: ./friend-lite | |
| run: npm ci | |
| - name: Create debug keystore (if not exists) | |
| run: | | |
| echo "Checking if friend-lite/android/app directory exists..." | |
| if [ -d "friend-lite/android/app" ]; then | |
| cd friend-lite/android/app | |
| echo "Current directory: $(pwd)" | |
| echo "Contents: $(ls -la)" | |
| 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" | |
| echo "Debug keystore created successfully" | |
| else | |
| echo "Debug keystore already exists, skipping creation" | |
| fi | |
| else | |
| echo "Error: friend-lite/android/app directory not found!" | |
| exit 1 | |
| fi | |
| - name: Make gradlew executable | |
| run: | | |
| if [ -f "friend-lite/android/gradlew" ]; then | |
| chmod +x friend-lite/android/gradlew | |
| echo "Made gradlew executable" | |
| else | |
| echo "Error: gradlew not found at friend-lite/android/gradlew" | |
| exit 1 | |
| fi | |
| - name: Build APK | |
| run: | | |
| if [ -d "friend-lite/android" ]; then | |
| cd friend-lite/android | |
| echo "Building APK from directory: $(pwd)" | |
| ./gradlew assembleRelease | |
| else | |
| echo "Error: friend-lite/android directory not found!" | |
| exit 1 | |
| fi | |
| - 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 |