Skip to content

Flipcash2 Build and Deploy #168

Flipcash2 Build and Deploy

Flipcash2 Build and Deploy #168

name: Flipcash2 Build and Deploy
env:
# The name of the main module repository
main_project_module: apps:flipcash:app
# The name of the Play Store
playstore_name: Flipcash
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
track:
description: 'Define PlayStore track name'
required: true
default: 'internal'
type: choice
options:
- internal
- alpha
- beta
- production
release_status:
description: 'Status of the release'
required: true
type: choice
default: 'completed'
options:
- completed
- draft
- inProgress
- halted
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Java env
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'corretto'
cache: 'gradle'
- name: Gradle build cache
uses: actions/cache@v4
with:
path: ~/.gradle/caches/build-cache-1
key: gradle-build-cache-${{ hashFiles('**/*.gradle.kts', 'gradle.properties') }}
restore-keys: |
gradle-build-cache-
- name: Setup Ruby env
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.2
bundler-cache: true
- name: Decode Google Services JSON file
uses: timheuer/base64-to-file@v1
with:
fileName: google-services.json
fileDir: ./apps/flipcash/app/src
encodedString: ${{ secrets.FLIPCASH2_GOOGLE_SERVICES }}
- name: Setup BugSnag API Key
run: echo BUGSNAG_API_KEY=\"${{ secrets.FLIPCASH_BUGSNAG_API_KEY }}\" > ./local.properties
- name: Setup Google Cloud Project Number
run: echo GOOGLE_CLOUD_PROJECT_NUMBER=${{ secrets.GOOGLE_CLOUD_PROJECT_NUMBER }} >> ./local.properties
- name: Setup Mixpanel API Key
run: echo MIXPANEL_API_KEY=\"${{ secrets.FLIPCASH_MIXPANEL_API_KEY }}\" >> ./local.properties
- name: Setup Coinbase OnRamp API Key
run: echo COINBASE_ONRAMP_API_KEY=${{ secrets.COINBASE_ONRAMP_API_KEY }} >> ./local.properties
- name: Run tests
run: bundle exec fastlane android flipcash_tests
env:
SKIP_COVERAGE: "true"
build-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Java env
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'corretto'
cache: 'gradle'
- name: Gradle build cache
uses: actions/cache@v4
with:
path: ~/.gradle/caches/build-cache-1
key: gradle-build-cache-${{ hashFiles('**/*.gradle.kts', 'gradle.properties') }}
restore-keys: |
gradle-build-cache-
- name: Setup Ruby env
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.2
bundler-cache: true
- name: Decode Google Services JSON file
uses: timheuer/base64-to-file@v1
with:
fileName: google-services.json
fileDir: ./apps/flipcash/app/src
encodedString: ${{ secrets.FLIPCASH2_GOOGLE_SERVICES }}
- name: Decode Upload Key Store file into location 1
uses: timheuer/base64-to-file@v1
id: signing_key
with:
fileName: key
fileDir: ./key
encodedString: ${{ secrets.UPLOAD_KEY_STORE }}
- name: Decode Upload Key Store file into location 2
uses: timheuer/base64-to-file@v1
with:
fileName: key
fileDir: ./apps/flipcash/app/key
encodedString: ${{ secrets.UPLOAD_KEY_STORE }}
- name: Setup BugSnag API Key
run: echo BUGSNAG_API_KEY=\"${{ secrets.FLIPCASH_BUGSNAG_API_KEY }}\" > ./local.properties
- name: Setup Google Cloud Project Number
run: echo GOOGLE_CLOUD_PROJECT_NUMBER=${{ secrets.GOOGLE_CLOUD_PROJECT_NUMBER }} >> ./local.properties
- name: Setup Mixpanel API Key
run: echo MIXPANEL_API_KEY=\"${{ secrets.FLIPCASH_MIXPANEL_API_KEY }}\" >> ./local.properties
- name: Setup Coinbase OnRamp API Key
run: echo COINBASE_ONRAMP_API_KEY=${{ secrets.COINBASE_ONRAMP_API_KEY }} >> ./local.properties
- name: Build release
run: bundle exec fastlane android build_flipcash
env:
STORE_FILE: ${{ steps.signing_key.outputs.filePath }}
STORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: |
apps/flipcash/app/build/outputs/bundle/release
apps/flipcash/app/build/outputs/apk/release
apps/flipcash/app/build/outputs/mapping/release/mapping.txt
deploy:
needs: [test, build-release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
persist-credentials: false
- name: Setup Ruby env
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.2
bundler-cache: true
- name: Decode Service Account Key JSON file
uses: timheuer/base64-to-file@v1
id: service_account_json_file
with:
fileName: serviceAccount.json
encodedString: ${{ secrets.FLIPCASH_SERVICE_ACCOUNT_KEY_JSON }}
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: apps/flipcash/app/build/outputs
- name: Upload to Play Store
run: bundle exec fastlane android upload_flipcash
env:
SERVICE_ACCOUNT_KEY_JSON: ${{ steps.service_account_json_file.outputs.filePath }}
PACKAGE_NAME: com.flipcash.app.android
PLAYSTORE_TRACK: ${{ github.event.inputs.track }}
RELEASE_STATUS: ${{ github.event.inputs.release_status }}
AAB_PATH: apps/flipcash/app/build/outputs/bundle/release/app-release.aab
MAPPING_PATH: apps/flipcash/app/build/outputs/mapping/release/mapping.txt
- name: Update release manifest
id: manifest
env:
SERVICE_ACCOUNT_KEY_JSON: ${{ steps.service_account_json_file.outputs.filePath }}
TRACKS: ${{ github.event.inputs.track }}
run: bash scripts/update-release-manifest.sh
- name: Commit & push manifest
env:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .well-known/release-manifest.json
git diff --cached --quiet && echo "No changes to commit" && exit 0
git commit -m "build: update release manifest"
git clean -fd
git checkout -- .
git pull --rebase https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git code/cash
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git HEAD:code/cash
- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: assets
path: |
${{ github.workspace }}/apps/flipcash/app/build/outputs/bundle/release
${{ github.workspace }}/apps/flipcash/app/build/outputs/apk/release