Merge pull request #3534 from ecency/chore/skills-accuracy #1803
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: | |
| # Keyed by ref so a PR build cannot cancel the development build, which is the | |
| # one that publishes the alpha release. | |
| group: android-build-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint-and-test: | |
| name: Lint & Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| 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: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Lint | |
| run: yarn lint | |
| - name: Typecheck | |
| run: yarn typecheck | |
| - name: Unit tests | |
| run: yarn test:ci | |
| android-build: | |
| name: Android Build | |
| needs: lint-and-test | |
| # 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 "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 | |
| echo "ANDROID_VERSION_CODE=$TIMESTAMP" >> $GITHUB_ENV | |
| - name: Resolve Android Sentry release metadata | |
| run: | | |
| APPLICATION_ID=$(ruby -e "c=File.read('android/app/build.gradle'); m=c.match(/applicationId\\s+['\\\"]([^'\\\"]+)['\\\"]/); puts(m && m[1] ? m[1] : 'app.esteem.mobile.android')") | |
| VERSION_NAME=$(node -p "require('./package.json').version") | |
| DIST="${ANDROID_VERSION_CODE}" | |
| RELEASE="${APPLICATION_ID}@${VERSION_NAME}+${DIST}" | |
| echo "SENTRY_RELEASE=$RELEASE" >> $GITHUB_ENV | |
| echo "SENTRY_DIST=$DIST" >> $GITHUB_ENV | |
| echo "Using Sentry release: $RELEASE" | |
| echo "Using Sentry dist: $DIST" | |
| - name: Bundle Android | |
| run: yarn run bundle:android | |
| - name: Execute Gradle APK build | |
| run: | | |
| cd android | |
| ./gradlew assembleRelease | |
| # Source maps are only used for error symbolication, so a transient Sentry | |
| # API error (e.g. HTTP 500) must not block the release build. The shared | |
| # retry helper retries transient failures; continue-on-error lets a | |
| # sustained Sentry outage degrade gracefully instead of failing the build. | |
| - name: Upload source maps to Sentry (Android) | |
| continue-on-error: true | |
| env: | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| run: | | |
| retry="$GITHUB_WORKSPACE/.github/scripts/sentry-retry.sh" | |
| BUNDLE_PATH=android/app/src/main/assets/index.android.bundle | |
| MAP_PATH=android/app/src/main/assets/index.android.bundle.map | |
| bash "$retry" npx sentry-cli releases new "$SENTRY_RELEASE" --org ecency --project ecency-mobile | |
| bash "$retry" npx sentry-cli releases files "$SENTRY_RELEASE" upload-sourcemaps \ | |
| --dist "$SENTRY_DIST" \ | |
| --org ecency --project ecency-mobile \ | |
| --rewrite \ | |
| "$BUNDLE_PATH" "$MAP_PATH" | |
| bash "$retry" npx sentry-cli releases finalize "$SENTRY_RELEASE" --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 |