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    steps:
37      - name: �� Checkout
38        uses: actions/checkout@v3
39        with:
40          submodules: true
41      - name: �� Decrypt secrets if possible
42        uses: ./.github/actions/expo-git-decrypt
43        with:
44          key: ${{ secrets.GIT_CRYPT_KEY_BASE64 }}
45      - name: ➕ Add `bin` to GITHUB_PATH
46        run: echo "$(pwd)/bin" >> $GITHUB_PATH
47      - name: ♻️ Restore caches
48        uses: ./.github/actions/expo-caches
49        id: expo-caches
50        with:
51          yarn-workspace: 'true'
52          yarn-tools: 'true'
53      - name: �� Yarn install
54        if: steps.expo-caches.outputs.yarn-workspace-hit != 'true'
55        run: yarn install --frozen-lockfile
56      - name: Install eas-cli
57        run: npm install -g eas-cli
58      - name: �� Check which flavor to build
59        id: flavor
60        uses: dorny/paths-filter@v2
61        with:
62          # this action fails when base is not set on schedule event
63          base: ${{ github.ref }}
64          filters: |
65            versioned:
66              - android/versioned-abis/**
67              - android/versioned-react-native/**
68              - android/expoview/src/versioned/**
69              - android/expoview/src/main/java/versioned/**
70              - android/**/*.gradle
71      - name: Resolve profile
72        id: profile
73        run: |
74          DISPATCH_PROFILE="${{ github.event.inputs.buildType }}"
75          IS_VERSIONED="${{ steps.flavor.outputs.versioned }}"
76          if [[ ! -z "$DISPATCH_PROFILE" ]]; then
77            echo "profile=$DISPATCH_PROFILE" >> $GITHUB_OUTPUT
78          elif [[ "${{ github.event.schedule }}" == "20 5 * * 1,3,5" ]]; then
79            echo "profile=versioned-client" >> $GITHUB_OUTPUT
80          elif [[ "${{ github.event.schedule }}" == "20 5 * * 1" ]]; then
81            echo "profile=versioned-client-add-sdk" >> $GITHUB_OUTPUT
82          elif [[ "$IS_VERSIONED" == "true" ]]; then
83            echo "profile=versioned-client" >> $GITHUB_OUTPUT
84          else
85            echo "profile=unversioned-client" >> $GITHUB_OUTPUT
86          fi
87      - name: Generate local credentials.json
88        working-directory: ./apps/eas-expo-go
89        run: |
90          cat >credentials.json <<EOL
91          {
92            "android": {
93              "keystore": {
94                "keystorePath": "release.keystore",
95                "keystorePassword": "$ANDROID_KEYSTORE_PASSWORD",
96                "keyAlias": "ExponentKey",
97                "keyPassword": "$ANDROID_KEY_PASSWORD"
98              }
99            }
100          }
101          EOL
102          echo $ANDROID_KEYSTORE_B64 | base64 -d > release.keystore
103        env:
104          ANDROID_KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }}
105          ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
106          ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
107      - name: Build
108        uses: ./.github/actions/eas-build
109        id: build
110        with:
111          platform: 'android'
112          profile: ${{ steps.profile.outputs.profile  }}
113          projectRoot: './apps/eas-expo-go'
114          expoToken: ${{ secrets.EAS_BUILD_BOT_TOKEN }}
115          resourceClass: large
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