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