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