1name: Android Shell App
2
3on:
4  workflow_dispatch: {}
5  schedule:
6    - cron: '20 5 * * 2,4,6' # 5:20 AM UTC time on every Tuesday, Thursday and Saturday
7  push:
8    paths:
9      - .github/workflows/shell-app-android.yml
10
11concurrency:
12  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
13  cancel-in-progress: true
14
15jobs:
16  build:
17    runs-on: ubuntu-20.04
18    strategy:
19      matrix:
20        ndk-version: [21.4.7075529]
21    steps:
22      - name: �� Checkout
23        uses: actions/checkout@v3
24        with:
25          submodules: true
26      - name: �� Use JDK 11
27        uses: actions/setup-java@v3
28        with:
29          distribution: 'temurin'
30          java-version: '11'
31      - name: ➕ Add `EXPO_ROOT_DIR` to GITHUB_ENV
32        run: echo "EXPO_ROOT_DIR=$(pwd)" >> $GITHUB_ENV
33      - name: ➕ Add `bin` to GITHUB_PATH
34        run: echo "$(pwd)/bin" >> $GITHUB_PATH
35      - name: ♻️ Restore caches
36        uses: ./.github/actions/expo-caches
37        id: expo-caches
38        with:
39          yarn-workspace: 'true'
40          git-lfs: 'true'
41          ndk: 'true'
42          ndk-version: ${{ matrix.ndk-version }}
43      - name: �� Pull Git LFS files
44        run: git lfs pull
45      - name: �� Yarn install
46        if: steps.expo-caches.outputs.yarn-workspace-hit != 'true'
47        run: yarn install --frozen-lockfile
48      - name: ��️ Build Android packages
49        env:
50          ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/${{ matrix.ndk-version }}/
51        run: expotools android-build-packages --packages all
52      - name: �� Clean Android build artifacts that would needlessly bloat the shell app
53        env:
54          ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/${{ matrix.ndk-version }}/
55        run: ./gradlew clean
56        working-directory: android
57      - name: ��️ Build shell app tarball
58        run: ./buildAndroidTarballLocally.sh
59      - name: ��️ Make an artifact
60        uses: actions/upload-artifact@v3
61        with:
62          name: android-shell-app
63          path: artifacts/android-shell-builder.tar.gz
64      - name: ��️ Upload shell app tarball to S3
65        if: ${{ github.event_name == 'workflow_dispatch' }}
66        env:
67          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
68          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
69          AWS_DEFAULT_REGION: 'us-east-1'
70          S3_URI: s3://exp-artifacts/android-shell-builder-${{ github.sha }}.tar.gz
71        run: |
72          aws s3 cp --acl public-read artifacts/android-shell-builder.tar.gz $S3_URI
73          echo "Release tarball uploaded to $S3_URI"
74          echo "You can deploy this by updating or creating a new file in https://github.com/expo/turtle/tree/master/shellTarballs/android"
75          echo "Then follow the deployment instructions: https://github.com/expo/turtle-deploy"
76      - name: ��️ Set the description for Slack message
77        if: ${{ github.event_name != 'push' }}
78        run: |
79          if [ ${{ github.event_name }} == 'schedule' ]; then
80            echo "SLACK_MESSAGE_DESCRIPTION=scheduled" >> $GITHUB_ENV
81          else
82            echo "SLACK_MESSAGE_DESCRIPTION=triggered by ${{ github.actor }}" >> $GITHUB_ENV
83          fi
84      - name: �� Notify on Slack
85        uses: 8398a7/action-slack@v3
86        if: ${{ github.event_name != 'push' }}
87        env:
88          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_ANDROID }}
90        with:
91          channel: '#expo-android'
92          status: ${{ job.status }}
93          fields: job,message,ref,eventName,author,took
94          author_name: Android Shell App (${{ env.SLACK_MESSAGE_DESCRIPTION }})
95