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