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