1name: Android Client - EAS Build
2
3on:
4  workflow_dispatch:
5    inputs:
6      buildType:
7        required: true
8        type: 'choice'
9        description: 'buildType'
10        options:
11          - versioned-client
12          - unversioned-client
13          - versioned-client-signed
14          - versioned-client-signed-apk
15          - versioned-client-add-sdk
16  schedule:
17    # 5:20 AM UTC time on every Monday, Wednesday and Friday
18    # Build a versioned client
19    - cron: '20 5 * * 1,3,5'
20    # 5:20 AM UTC time on every Monday
21    # Run versioning process for the next sdk and build a versioned client
22    - cron: '20 5 * * 1'
23  pull_request:
24    paths:
25      - .github/workflows/client-android-eas.yml
26      - apps/eas-expo-go/**
27
28
29concurrency:
30  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
31  cancel-in-progress: true
32
33jobs:
34  build:
35    runs-on: ubuntu-20.04
36    if: ${{ github.actor != 'dependabot[bot]' }}
37    steps:
38      - name: �� Checkout
39        uses: actions/checkout@v3
40        with:
41          submodules: true
42      - name: �� Decrypt secrets if possible
43        uses: ./.github/actions/expo-git-decrypt
44        with:
45          key: ${{ secrets.GIT_CRYPT_KEY_BASE64 }}
46      - name: ➕ Add `bin` to GITHUB_PATH
47        run: echo "$(pwd)/bin" >> $GITHUB_PATH
48      - name: ♻️ Restore caches
49        uses: ./.github/actions/expo-caches
50        id: expo-caches
51        with:
52          yarn-workspace: 'true'
53          yarn-tools: 'true'
54      - name: �� Yarn install
55        if: steps.expo-caches.outputs.yarn-workspace-hit != 'true'
56        run: yarn install --frozen-lockfile
57      - name: Install eas-cli
58        run: npm install -g eas-cli
59      - name: �� Check which flavor to build
60        id: flavor
61        uses: dorny/paths-filter@v2
62        with:
63          # this action fails when base is not set on schedule event
64          base: ${{ github.ref }}
65          filters: |
66            versioned:
67              - android/versioned-abis/**
68              - android/versioned-react-native/**
69              - android/expoview/src/versioned/**
70              - android/expoview/src/main/java/versioned/**
71              - android/**/*.gradle
72      - name: Resolve profile
73        id: profile
74        run: |
75          DISPATCH_PROFILE="${{ github.event.inputs.buildType }}"
76          IS_VERSIONED="${{ steps.flavor.outputs.versioned }}"
77          if [[ ! -z "$DISPATCH_PROFILE" ]]; then
78            echo "profile=$DISPATCH_PROFILE" >> $GITHUB_OUTPUT
79          elif [[ "${{ github.event.schedule }}" == "20 5 * * 1,3,5" ]]; then
80            echo "profile=versioned-client" >> $GITHUB_OUTPUT
81          elif [[ "${{ github.event.schedule }}" == "20 5 * * 1" ]]; then
82            echo "profile=versioned-client-add-sdk" >> $GITHUB_OUTPUT
83          elif [[ "$IS_VERSIONED" == "true" ]]; then
84            echo "profile=versioned-client" >> $GITHUB_OUTPUT
85          else
86            echo "profile=unversioned-client" >> $GITHUB_OUTPUT
87          fi
88      - name: Generate local credentials.json
89        working-directory: ./apps/eas-expo-go
90        run: |
91          cat >credentials.json <<EOL
92          {
93            "android": {
94              "keystore": {
95                "keystorePath": "release.keystore",
96                "keystorePassword": "$ANDROID_KEYSTORE_PASSWORD",
97                "keyAlias": "ExponentKey",
98                "keyPassword": "$ANDROID_KEY_PASSWORD"
99              }
100            }
101          }
102          EOL
103          echo $ANDROID_KEYSTORE_B64 | base64 -d > release.keystore
104        env:
105          ANDROID_KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }}
106          ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
107          ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
108      - name: Build
109        uses: ./.github/actions/eas-build
110        id: build
111        with:
112          platform: 'android'
113          profile: ${{ steps.profile.outputs.profile  }}
114          projectRoot: './apps/eas-expo-go'
115          expoToken: ${{ secrets.EAS_BUILD_BOT_TOKEN }}
116          noWait: ${{ github.event.schedule }}
117          message: ${{ github.event.pull_request.title }}
118      - name: On workflow canceled
119        if: ${{ cancelled() && steps.build.outputs.build_id }}
120        run: eas build:cancel ${{ steps.build.outputs.build_id }}
121        working-directory: ./apps/eas-expo-go
122        env:
123          EXPO_TOKEN: ${{ secrets.EAS_BUILD_BOT_TOKEN }}
124          EAS_BUILD_PROFILE: ${{ steps.profile.outputs.profile  }}
125