Build and Distribute Android App #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Distribute Android App | |
concurrency: | |
group: main | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ develop, main ] | |
jobs: | |
startSlackNotification: | |
name: Slack Starting Notification | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
export BUILD_NUM=$((${{ github.run_number }})) | |
export GITHUB_WORKFLOW_URL=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID | |
echo "BUILD_NUM=$BUILD_NUM" >> $GITHUB_ENV | |
echo "GITHUB_WORKFLOW_URL=$GITHUB_WORKFLOW_URL" >> $GITHUB_ENV | |
- name: Slack Notification | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_CHANNEL: amazon-location-services-builds | |
SLACK_COLOR: "#FFFF00" | |
SLACK_ICON_EMOJI: ":hammer:" | |
SLACK_LINK_NAMES: true | |
SLACK_TITLE: ${{ format('Android Build №{0} started...', env.BUILD_NUM) }} | |
SLACK_MESSAGE: | | |
${{ format('Branch: `{0}`', github.ref_name) }} | |
SLACK_FOOTER: ${{ github.ref }} | ${{ env.GITHUB_WORKFLOW_URL }} | |
SLACK_USERNAME: CI/CD Bot | |
MSG_MINIMAL: true | |
build-android: | |
name: Build Android | |
env: | |
STORE_FILE_PATH: "../.signing/keystore.jks" | |
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }} | |
KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Ruby with rbenv | |
run: | | |
rbenv install -s 3.3.5 | |
rbenv local 3.3.5 | |
bundle install | |
- name: Setup Signing | |
working-directory: | |
run: | | |
mkdir -p .signing | |
base64 -d <<< ${{ secrets.KEYSTORE }} > .signing/keystore.jks | |
base64 -d <<< ${{ secrets.SECRETS }} > custom.properties | |
ls .signing | |
- name: Build APK | |
run: | | |
export BUILD_NUM=$((${{ github.run_number }})) | |
echo Building $BUILD_NUM | |
bundle exec fastlane build_apk version_code:$BUILD_NUM build_type:Release | |
- name: Distribute APK to firebase | |
run: | | |
bundle exec fastlane distribute_firebase \ | |
app_id:${{ secrets.FIREBASE_APP_ID }} \ | |
changelog:"Amazon Location Dev Build" \ | |
firebase_cli_token:${{ secrets.FIREBASE_TOKEN }} \ | |
aab_path:./app/build/outputs/apk/release/app-release.apk | |
- name: Build AAB | |
if: false | |
run: | | |
export BUILD_NUM=$((${{ github.run_number }})) | |
echo Building $BUILD_NUM | |
bundle exec fastlane build_aab version_code:$BUILD_NUM build_type:Release | |
- name: Distribute AAB to google play | |
if: false | |
run: | | |
bundle exec fastlane distribute_play_store \ | |
package_name:com.aws.amazonlocation \ | |
track:internal \ | |
json_key:./.signing/play_store_key.json \ | |
aab_path:./app/build/outputs/bundle/release/app-release.aab | |
slackNotification: | |
name: slack | |
needs: [build-android] | |
if: always() | |
runs-on: ubuntu-latest | |
env: | |
SUCCESS: ${{ needs.build-android.result == 'success' }} | |
steps: | |
- run: | | |
export BUILD_NUM=$((${{ github.run_number }})) | |
export GITHUB_WORKFLOW_URL=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID | |
echo "BUILD_NUM=$BUILD_NUM" >> $GITHUB_ENV | |
echo "GITHUB_WORKFLOW_URL=$GITHUB_WORKFLOW_URL" >> $GITHUB_ENV | |
- name: Slack Notification | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_CHANNEL: amazon-location-services-builds | |
SLACK_COLOR: ${{ env.SUCCESS == 'true' && 'success' || 'failure' }} | |
SLACK_ICON_EMOJI: ":tophat:" | |
SLACK_LINK_NAMES: true | |
SLACK_TITLE: ${{ format('Android build №{0} {1}', env.BUILD_NUM, env.SUCCESS == 'true' && 'finished successfully :tada:' || 'failed!') }} | |
SLACK_MESSAGE: | | |
${{ format('Branch: `{0}`', github.ref_name) }} | |
${{ format('Build Number: `{0}`', env.BUILD_NUM) }} | |
${{ format('URL: {0}', env.GITHUB_WORKFLOW_URL) }} | |
SLACK_FOOTER: ${{ github.ref }} | ${{ env.GITHUB_WORKFLOW_URL }} | |
SLACK_USERNAME: CI/CD Bot | |
MSG_MINIMAL: true |