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 with: 52 bundler-cache: true 53 - run: sudo apt-get install git-crypt 54 - name: decrypt secrets if possible 55 env: 56 GIT_CRYPT_KEY_BASE64: ${{ secrets.GIT_CRYPT_KEY_BASE64 }} 57 run: | 58 if [ -z "${GIT_CRYPT_KEY_BASE64}" ]; then 59 echo 'git-crypt key not present in environment' 60 else 61 git crypt unlock <(echo $GIT_CRYPT_KEY_BASE64 | base64 --decode) 62 fi 63 - uses: actions/cache@v1 64 with: 65 path: ~/.gradle/caches 66 key: ${{ runner.os }}-gradle-${{ hashFiles('android/*.gradle*') }} 67 restore-keys: | 68 ${{ runner.os }}-gradle- 69 - uses: actions/cache@v2 70 id: cache-android-ndk 71 with: 72 path: /usr/local/lib/android/sdk/ndk/19.2.5345600/ 73 key: ${{ runner.os }}-ndk-19.2.5345600 74 restore-keys: | 75 ${{ runner.os }}-ndk- 76 - name: Install NDK 77 if: steps.cache-android-ndk.outputs.cache-hit != 'true' 78 run: | 79 sudo $ANDROID_HOME/tools/bin/sdkmanager --install "ndk;19.2.5345600" 80 - run: echo "$(pwd)/bin" >> $GITHUB_PATH 81 - name: Build APK 82 env: 83 ANDROID_KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }} 84 ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} 85 ANDROID_KEY_ALIAS: ExponentKey 86 ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} 87 ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/19.2.5345600/ 88 run: | 89 if [ -z "$ANDROID_KEYSTORE_B64" ]; then 90 echo "External build detected, APK will not be signed" 91 fastlane android build build_type:Release sign:false 92 else 93 echo "Internal build detected, APK will be signed" 94 echo $ANDROID_KEYSTORE_B64 | base64 -d > android/app/release-key.jks 95 fastlane android build build_type:Release 96 fi 97 - uses: actions/upload-artifact@v2 98 with: 99 name: android-apk 100 path: android/app/build/outputs/apk 101 - name: Store daemon logs for debugging crashes 102 if: failure() 103 uses: actions/upload-artifact@v2 104 with: 105 name: gradle-daemon-logs 106 path: ~/.gradle/daemon 107 - name: Upload APK to S3 and update staging versions endpoint 108 if: ${{ github.event.inputs.releaseAPK == 'release-apk' }} 109 run: bin/expotools client-build --platform android --release 110 env: 111 AWS_ACCESS_KEY_ID: AKIAJ3SWUQ4QLNQC7FXA 112 AWS_SECRET_ACCESS_KEY: ${{ secrets.android_client_build_aws_secret_key }} 113 EXPO_VERSIONS_SECRET: ${{ secrets.expo_versions_secret }} 114 - name: Upload APK to Google Play and release to production 115 if: ${{ github.event.inputs.releaseGooglePlay == 'release-google-play' }} 116 run: fastlane android prod_release 117 env: 118 SUPPLY_JSON_KEY_DATA: ${{ secrets.SUPPLY_JSON_KEY_DATA }} 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: custom 127 fields: author,commit,ref,workflow 128 custom_payload: | 129 { 130 username: 'github-actions', 131 icon_emoji: ':octocat:', 132 attachments: [{ 133 color: 'danger', 134 text: `${process.env.AS_WORKFLOW}@${process.env.AS_REF} failed: ${process.env.AS_COMMIT} by ${process.env.AS_AUTHOR}`, 135 }] 136 } 137