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