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