Performance: optimizations #422
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: Android Build | |
| on: | |
| pull_request: | |
| types: [ready_for_review, synchronize, labeled] | |
| push: | |
| branches: | |
| - development | |
| concurrency: | |
| group: android-build | |
| cancel-in-progress: true | |
| jobs: | |
| android-build: | |
| name: Android Build | |
| # Run only when the review is Approved, PR targets 'development', and it's a same-repo PR | |
| if: > | |
| (github.event_name == 'pull_request') || | |
| (github.event_name == 'push' && github.ref == 'refs/heads/development') | |
| runs-on: macos-latest | |
| steps: | |
| - name: Show host machine information | |
| run: uname -a | |
| - name: Checkout PR head or development branch | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: > | |
| ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' && github.repository || | |
| github.event.pull_request.head.repo.full_name }} | |
| ref: > | |
| ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' && 'development' || | |
| github.event.pull_request.head.sha }} | |
| - name: Create .env file | |
| run: | | |
| echo "ACTIVITY_WEBSOCKET_URL=${{ secrets.ACTIVITY_WEBSOCKET_URL }}" >> .env | |
| echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> .env | |
| echo "DEFAULT_PIN=${{ secrets.DEFAULT_PIN }}" >> .env | |
| echo "ECENCY_BACKEND_API=${{ secrets.ECENCY_BACKEND_API }}" >> .env | |
| echo "NEW_IMAGE_API=${{ secrets.NEW_IMAGE_API }}" >> .env | |
| echo "PIN_KEY=${{ secrets.PIN_KEY }}" >> .env | |
| echo "SERVER_LIST_API=${{ secrets.SERVER_LIST_API }}" >> .env | |
| echo "USER_AGENT=${{ secrets.USER_AGENT }}" >> .env | |
| echo "PLAUSIBLE_API_KEY=${{ secrets.PLAUSIBLE_API_KEY }}" >> .env | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install npm dependency | |
| run: yarn install | |
| - name: Run gradle patch script | |
| run: bash patch-gradle.sh | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: "17" | |
| distribution: "temurin" | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| with: | |
| cmdline-tools-version: 12266719 | |
| - uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Create Google Services JSON File | |
| env: | |
| GOOGLE_JSON: ${{ secrets.GOOGLE_JSON }} | |
| run: echo $GOOGLE_JSON | base64 --decode > ./android/app/google-services.json | |
| - name: Upload-keystore generator | |
| run: | | |
| echo "${{secrets.UPLOAD_KEYSTORE}}" > upload.keystore.asc | |
| base64 -d --input upload.keystore.asc --output android/app/key.jks | |
| - name: Key.Properties | |
| run: | | |
| echo "keyPassword=${{ secrets.UPLOAD_KEYSTORE_PASSPHRASE }}" >> ./android/key.properties | |
| echo "storePassword=${{ secrets.UPLOAD_KEYSTORE_PASSPHRASE }}" >> ./android/key.properties | |
| echo "keyAlias=${{ secrets.ALIAS }}" >> ./android/key.properties | |
| - name: Generate signing report | |
| run: | | |
| cd android | |
| ./gradlew signingReport | |
| cd .. | |
| - name: Set version code | |
| run: | | |
| TIMESTAMP=$(date +%s) | |
| echo "Setting version code to: $TIMESTAMP" | |
| sed -i '' "s/versionCode .*/versionCode $TIMESTAMP/" android/app/build.gradle | |
| - name: Bundle Android | |
| run: yarn run bundle:android | |
| - name: Execute Gradle APK build | |
| run: | | |
| cd android | |
| ./gradlew assembleRelease | |
| - name: Upload source maps to Sentry (Android) | |
| env: | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| DIST=$(date +%s) | |
| BUNDLE_PATH=android/app/src/main/assets/index.android.bundle | |
| MAP_PATH=android/app/src/main/assets/index.android.bundle.map | |
| npx sentry-cli releases new "$VERSION-$DIST" --org ecency --project ecency-mobile | |
| npx sentry-cli releases files "$VERSION-$DIST" upload-sourcemaps \ | |
| --dist "$DIST" \ | |
| --org ecency --project ecency-mobile \ | |
| --rewrite \ | |
| "$BUNDLE_PATH" "$MAP_PATH" | |
| npx sentry-cli releases finalize "$VERSION-$DIST" --org ecency --project ecency-mobile | |
| - name: Upload APK application | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Ecency-APK | |
| path: ./android/app/build/outputs/apk/release/app-release.apk | |
| retention-days: 90 | |
| - name: Execute Gradle Bundle build | |
| run: | | |
| cd android | |
| ./gradlew bundleRelease | |
| - name: Upload App bundle to Releases | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Ecency-Bundle | |
| path: ./android/app/build/outputs/bundle/release/app-release.aab | |
| android-deploy: | |
| name: Deploy Android Build | |
| needs: android-build | |
| # Only deploy if the trigger is a pull_request with 'deploy-pr-build' label or a push to 'development' | |
| if: > | |
| (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy-pr-build')) || | |
| (github.event_name == 'push' && github.ref == 'refs/heads/development') | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get Android Build from artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Deploy to Play Store (BETA) | |
| id: deploy | |
| uses: r0adkll/upload-google-play@v1 | |
| with: | |
| serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} | |
| packageName: app.esteem.mobile.android | |
| releaseFiles: Ecency-Bundle/app-release.aab | |
| track: alpha | |
| status: completed |