Skip to content

Deploy to Google Play For Production #12

Deploy to Google Play For Production

Deploy to Google Play For Production #12

---
# Nightly compile for e2e testing
name: Deploy to Google Play For Prod deploy
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
# TODO To be combined into human app build when it works.
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
# push:
# branches:
# - github-actions
# - main
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
check_date:
runs-on: ubuntu-latest
name: Check latest commit
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
steps:
- uses: actions/checkout@v3
- name: print latest_commit
run: echo ${{ github.sha }}
- id: should_run
continue-on-error: true
name: check latest commit is less than a day
if: ${{ github.event_name == 'schedule' }}
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false"
node-deb-gh-build-play:
# The type of runner that the job will run on
# https://github.com/Apple-Actions/Example-iOS/blob/master/.github/workflows/test.yml
runs-on: ubuntu-latest
needs: check_date
continue-on-error: true
strategy:
matrix:
node-version: ['20']
outputs:
prnum: ${{ steps.prnum.outputs.value }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
# https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-java-with-gradle
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
# https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-java-with-gradle
- name: Set up adopt JDK 1.17
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'
# https://www.runway.team/blog/ci-cd-pipeline-android-app-fastlane-github-actions
# Because fastlane stuff is in android, we need working-directory
- name: Set up ruby env
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.1
bundler-cache: true
working-directory: android
# We'll do this when we have android-specific tests...
# - name: Run tests
# run: |
# cd android
# bundle exec fastlane android test
# echo -n "::set-output name=value::$(git log --perl-regexp --pretty='%s' | grep 'Merge #' | head -n1 | cut -d'#' -f2)-$(git describe --long 2>/dev/null || git describe --all --long --always)"
- name: Get PR Number
id: prnum
run: |
echo -n "value=$(bin/getDescribeString.sh gh-play)" >> "$GITHUB_OUTPUT"
shell: bash
- name: Decode Service Account Key JSON File
uses: timheuer/base64-to-file@v1
id: service_account_json_file
with:
fileName: "fastlane-android-google-play-key.json"
encodedString: ${{ secrets.GPLAY_SERVICE_ACCOUNT_KEY_JSON }}
- name: Decode Keystore File
uses: timheuer/base64-to-file@v1
id: android_keystore
with:
fileName: "android-signing-keystore.jks"
encodedString: ${{ secrets.KEYSTORE_FILE }}
# https://github.com/android-actions/setup-android
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Building webapp
run: |
export platform="github-actions-play"
export serverprefix="fieldmark"
export VITE_CLUSTER_ADMIN_GROUP_NAME=cluster-admin
export VITE_COMMIT_VERSION=$(bin/getDescribeString.sh android)
export VITE_SHOW_WIPE=true
export VITE_SHOW_MINIFAUXTON=false
export VITE_DIRECTORY_HOST=db.fieldmark.app
export VITE_DIRECTORY_PORT=443
export VITE_PRODUCTION_BUILD=true
export VITE_SERVICES=FAIMSTEXT
export VITE_PROD_BUILD=true
export VITE_TAG=prodAndroid
export VITE_BUGSNAG_KEY=${{secrets.BUGSNAG_KEY}}
git clean -xfd
npm ci
npm run build
# https://capacitorjs.com/docs/android
# The bundle install shouldn't be necessary, but given we've got ios and android in...
- run: npx cap update android
- run: npx cap sync --deployment android
- name: Fastlane
run: |
cd android
bundle install
bundle exec fastlane deploy_fieldmark_production
env:
JAVA_KEYSTORE: ${{ steps.android_keystore.outputs.filePath }}
JAVA_KEYSTORE_PASSWORD: ${{ secrets.JAVA_KEYSTORE_PASSWORD }}
JAVA_KEY: ${{ secrets.JAVA_KEY}}
JAVA_KEY_PASSWORD: ${{ secrets.JAVA_KEY_PASSWORD }}
ANDROID_JSON_KEY_FILE: ${{ steps.service_account_json_file.outputs.filePath }}
serverprefix: "fieldmark"
prnum: ${{steps.prnum.outputs.value}}
# - run: cd android && ./gradlew assembleDebug
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: assets
path: |
${{ github.workspace }}/android/app/build/outputs/bundle/release
# - uses: "marvinpinto/action-automatic-releases@latest"
# with:
# repo_token: "${{ secrets.GITHUB_TOKEN }}"
# automatic_release_tag: "latest-android"
# prerelease: true
# title: "Android APK Development Build"
# files: |
# LICENSE
# *.apk