1name: Android Client 2 3on: 4 workflow_dispatch: 5 inputs: 6 releaseAPK: 7 description: 'type "release-apk" to confirm upload to S3' 8 required: false 9 releaseGooglePlay: 10 description: 'type "release-google-play" to confirm release to Google Play' 11 required: false 12 pull_request: 13 paths: 14 - .github/workflows/client-android.yml 15 - secrets/** 16 - android/** 17 - fastlane/** 18 - Gemfile.lock 19 - .ruby-version 20 - yarn.lock 21 push: 22 branches: [master, sdk-*] 23 paths: 24 - .github/workflows/client-android.yml 25 - secrets/** 26 - android/** 27 - fastlane/** 28 - Gemfile.lock 29 - .ruby-version 30 - yarn.lock 31 32jobs: 33 build: 34 runs-on: ubuntu-18.04 35 steps: 36 - uses: actions/checkout@v2 37 with: 38 submodules: true 39 - name: Get yarn cache directory path 40 id: yarn-cache-dir-path 41 run: echo "::set-output name=dir::$(yarn cache dir)" 42 - uses: actions/cache@v2 43 with: 44 path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 45 key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} 46 restore-keys: | 47 ${{ runner.os }}-yarn- 48 - run: yarn install --frozen-lockfile 49 - uses: ruby/setup-ruby@v1 50 with: 51 bundler-cache: true 52 - run: sudo apt-get install git-crypt 53 - name: decrypt secrets if possible 54 env: 55 GIT_CRYPT_KEY_BASE64: ${{ secrets.GIT_CRYPT_KEY_BASE64 }} 56 run: | 57 if [ -z "${GIT_CRYPT_KEY_BASE64}" ]; then 58 echo 'git-crypt key not present in environment' 59 else 60 git crypt unlock <(echo $GIT_CRYPT_KEY_BASE64 | base64 --decode) 61 fi 62 - uses: actions/cache@v2 63 with: 64 path: ~/.gradle/caches 65 key: ${{ runner.os }}-gradle-${{ hashFiles('android/*.gradle*') }} 66 restore-keys: | 67 ${{ runner.os }}-gradle- 68 - uses: actions/cache@v2 69 id: cache-android-ndk 70 with: 71 path: /usr/local/lib/android/sdk/ndk/19.2.5345600/ 72 key: ${{ runner.os }}-ndk-19.2.5345600 73 restore-keys: | 74 ${{ runner.os }}-ndk- 75 - name: Install NDK 76 if: steps.cache-android-ndk.outputs.cache-hit != 'true' 77 run: | 78 sudo $ANDROID_HOME/tools/bin/sdkmanager --install "ndk;19.2.5345600" 79 - run: echo "$(pwd)/bin" >> $GITHUB_PATH 80 - name: Build APK 81 env: 82 ANDROID_KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }} 83 ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} 84 ANDROID_KEY_ALIAS: ExponentKey 85 ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} 86 ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/19.2.5345600/ 87 run: | 88 if [ -z "$ANDROID_KEYSTORE_B64" ]; then 89 echo "External build detected, APK will not be signed" 90 fastlane android build build_type:Release sign:false 91 else 92 echo "Internal build detected, APK will be signed" 93 echo $ANDROID_KEYSTORE_B64 | base64 -d > android/app/release-key.jks 94 fastlane android build build_type:Release 95 fi 96 - uses: actions/upload-artifact@v2 97 with: 98 name: android-apk 99 path: android/app/build/outputs/apk 100 - name: Store daemon logs for debugging crashes 101 if: failure() 102 uses: actions/upload-artifact@v2 103 with: 104 name: gradle-daemon-logs 105 path: ~/.gradle/daemon 106 - name: Upload APK to S3 and update staging versions endpoint 107 if: ${{ github.event.inputs.releaseAPK == 'release-apk' }} 108 run: bin/expotools client-build --platform android --release 109 env: 110 AWS_ACCESS_KEY_ID: AKIAJ3SWUQ4QLNQC7FXA 111 AWS_SECRET_ACCESS_KEY: ${{ secrets.android_client_build_aws_secret_key }} 112 EXPO_VERSIONS_SECRET: ${{ secrets.expo_versions_secret }} 113 - name: Upload APK to Google Play and release to production 114 if: ${{ github.event.inputs.releaseGooglePlay == 'release-google-play' }} 115 run: fastlane android prod_release 116 env: 117 SUPPLY_JSON_KEY_DATA: ${{ secrets.SUPPLY_JSON_KEY_DATA }} 118 - name: Notify on Slack 119 uses: 8398a7/action-slack@v3 120 if: failure() && (github.event.ref == 'refs/heads/master' || startsWith(github.event.ref, 'refs/heads/sdk-')) 121 env: 122 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 123 SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_android }} 124 with: 125 channel: '#platform-android' 126 status: ${{ job.status }} 127 fields: job,commit,ref,eventName,author,took 128 author_name: Expo Go (Android) 129