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-18.04
18    steps:
19      - uses: actions/checkout@v2
20        with:
21          submodules: true
22      - name: Get cache key of git lfs files
23        id: git-lfs
24        run: echo "::set-output name=sha256::$(git lfs ls-files | openssl dgst -sha256)"
25      - uses: actions/cache@v2
26        with:
27          path: .git/lfs
28          key: ${{ steps.git-lfs.outputs.sha256 }}
29      - run: git lfs pull
30      - run: echo "$(pwd)/bin" >> $GITHUB_PATH
31      - run: echo "EXPO_ROOT_DIR=$(pwd)" >> $GITHUB_ENV
32      - name: Get yarn cache directory path
33        id: yarn-cache-dir-path
34        run: echo "::set-output name=dir::$(yarn cache dir)"
35      - uses: actions/cache@v2
36        with:
37          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
38          key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
39          restore-keys: |
40            ${{ runner.os }}-yarn-
41      - run: yarn install --frozen-lockfile
42      - uses: actions/cache@v2
43        with:
44          path: ~/.gradle/caches
45          key: ${{ runner.os }}-gradle-${{ hashFiles('android/*.gradle*') }}
46          restore-keys: |
47            ${{ runner.os }}-gradle-
48      - uses: actions/cache@v2
49        id: cache-android-ndk
50        with:
51          path: /usr/local/lib/android/sdk/ndk/19.2.5345600/
52          key: ${{ runner.os }}-ndk-19.2.5345600
53          restore-keys: |
54            ${{ runner.os }}-ndk-
55      - name: Install NDK
56        if: steps.cache-android-ndk.outputs.cache-hit != 'true'
57        run: |
58          sudo $ANDROID_SDK_ROOT/tools/bin/sdkmanager --install "ndk;19.2.5345600"
59      - name: Build Android packages
60        env:
61          ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/19.2.5345600/
62        run: expotools android-build-packages --packages all
63      - name: Clean Android build artifacts that would needlessly bloat the shell app
64        env:
65          ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/19.2.5345600/
66        run: ./gradlew clean
67        working-directory: android
68      - name: Build shell app tarball
69        run: ./buildAndroidTarballLocally.sh
70      - name: Make an artifact
71        uses: actions/upload-artifact@v2
72        with:
73          name: android-shell-app
74          path: artifacts/android-shell-builder.tar.gz
75      - name: Upload shell app tarball to S3
76        if: ${{ github.event_name == 'workflow_dispatch' }}
77        env:
78          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
79          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
80          S3_URI: s3://exp-artifacts/android-shell-builder-${{ github.sha }}.tar.gz
81        run: |
82          aws s3 cp --acl public-read artifacts/android-shell-builder.tar.gz $S3_URI
83          echo "Release tarball uploaded to $S3_URI"
84          echo "You can deploy this by updating or creating a new file in https://github.com/expo/turtle/tree/master/shellTarballs/android"
85          echo "Then follow the deployment instructions: https://github.com/expo/turtle-deploy"
86      - name: Set the description for slack message
87        if: ${{ github.event_name != 'push' }}
88        run: |
89          if [ ${{ github.event_name }} == 'schedule' ]; then
90            echo "SLACK_MESSAGE_DESCRIPTION=scheduled" >> $GITHUB_ENV
91          else
92            echo "SLACK_MESSAGE_DESCRIPTION=triggered by ${{ github.actor }}" >> $GITHUB_ENV
93          fi
94      - uses: 8398a7/action-slack@v3
95        if: ${{ github.event_name != 'push' }}
96        env:
97          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_ANDROID }}
99        with:
100          channel: '#platform-android'
101          status: ${{ job.status }}
102          fields: job,message,ref,eventName,author,took
103          author_name: Android Shell App (${{ env.SLACK_MESSAGE_DESCRIPTION }})
104