-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/npm_and_yarn/sequelize-typescri…
…pt-2.1.6
- Loading branch information
Showing
2 changed files
with
303 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
################################################################################## | ||
# About | ||
################################################################################## | ||
#Temporary action to he | ||
#Must specify all below secrets and variables - see documentation for details | ||
|
||
################################################################################## | ||
# Configuration | ||
################################################################################## | ||
env: | ||
DEPLOYMENT_NAME: 'early_family_math' | ||
APP_CODE_BRANCH: 'master' | ||
DEPLOYMENT_REPO: 'IDEMSInternational/efm-app-content.git' | ||
PARENT_DEPLOYMENT_REPO: '' | ||
PARENT_DEPLOYMENT_NAME: '' | ||
PARENT_DEPLOYMENT_BRANCH: '' | ||
DEPLOYMENT_PRIVATE_KEY: ${{secrets.DEPLOYMENT_PRIVATE_KEY}} | ||
FIREBASE_CONFIG: ${{secrets.FIREBASE_CONFIG_TS}} | ||
|
||
################################################################################## | ||
# Main Code | ||
################################################################################## | ||
name: EFM App - Build | ||
on: | ||
workflow_call: | ||
inputs: | ||
artifact-name: | ||
description: Name of the artifact to upload | ||
type: string | ||
default: www | ||
build-flags: | ||
description: Additional flags to pass to build command (e.g. base-href) | ||
type: string | ||
default: "" | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out app code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{env.APP_CODE_BRANCH}} | ||
|
||
- name: Checkout parent repo if needed | ||
if: env.PARENT_DEPLOYMENT_REPO != '' | ||
uses: actions/checkout@v3 | ||
with: | ||
path: ".idems_app/deployments/${{env.PARENT_DEPLOYMENT_NAME}}" | ||
repository: ${{env.PARENT_DEPLOYMENT_REPO}} | ||
ref: ${{env.PARENT_DEPLOYMENT_BRANCH}} | ||
|
||
- name: Checkout deployment | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: ${{env.DEPLOYMENT_REPO}} | ||
path: ".idems_app/deployments/${{env.DEPLOYMENT_NAME}}" | ||
ref: 'main' | ||
|
||
- name: Populate Encryption key | ||
if: env.DEPLOYMENT_PRIVATE_KEY != '' | ||
run: echo "${{env.DEPLOYMENT_PRIVATE_KEY}}" > ./.idems_app/deployments/${{env.DEPLOYMENT_NAME}}/encrypted/private.key | ||
|
||
- name: Populate firebaseConfig.ts | ||
if: ${{env.FIREBASE_CONFIG}} | ||
run: echo $FIREBASE_CONFIG > src/environments/firebaseConfig.ts | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
- name: Cache node modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: ./.yarn/cache | ||
# If cachebusting required (e.g. breaking yarn changes on update) change `v1` to another number | ||
key: ${{ runner.os }}-node-modules-yarn-v1-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-node-modules-yarn-v1- | ||
- name: Install node modules | ||
run: yarn install | ||
|
||
- name: Set deployment | ||
run: yarn workflow deployment set $DEPLOYMENT_NAME | ||
|
||
- name: Build | ||
run: yarn build ${{inputs.build-flags}} | ||
|
||
# Use github pages upload artifact action to compress and upload | ||
- name: Upload artifact | ||
uses: actions/[email protected] | ||
with: | ||
path: "www/" | ||
name: ${{inputs.artifact-name}} | ||
################################################################################## | ||
# Links | ||
################################################################################## | ||
|
||
# Create a reusable workflow to build deployment app | ||
# https://colinsalmcorner.com/musings-on-reusable-workflows/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
################################################################################## | ||
# About | ||
################################################################################## | ||
#Temporary action to build efm android app | ||
################################################################################## | ||
# Configuration | ||
################################################################################## | ||
env: | ||
# Secrets | ||
APP_ID: 'international.idems.early_family_math' | ||
APP_NAME: 'Early Family Math' | ||
DEPLOYMENT_NAME: 'early_family_math' | ||
APP_CODE_BRANCH: 'master' | ||
DEPLOYMENT_REPO: 'IDEMSInternational/efm-app-content.git' | ||
PARENT_DEPLOYMENT_REPO: '' | ||
PARENT_DEPLOYMENT_NAME: '' | ||
PARENT_DEPLOYMENT_BRANCH: '' | ||
GOOGLE_SERVICES_JSON: ${{secrets.GOOGLE_SERVICES_JSON}} | ||
SIGNING_KEY: ${{secrets.SIGNING_KEY}} | ||
ALIAS: ${{secrets.ALIAS}} | ||
KEY_STORE_PASSWORD: ${{secrets.KEY_STORE_PASSWORD}} | ||
KEY_PASSWORD: ${{secrets.KEY_PASSWORD}} | ||
|
||
################################################################################## | ||
# Main Code | ||
################################################################################## | ||
name: EFM Android Build | ||
|
||
# Only keep one active build per ref (e.g. pr branch, push branch, triggering workflow ref) | ||
concurrency: | ||
group: android-build-${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
############################################################################# | ||
# Build web | ||
############################################################################# | ||
web_build: | ||
uses: ./.github/workflows/efm-appbuild.yml | ||
secrets: inherit | ||
|
||
############################################################################# | ||
# Build android | ||
############################################################################# | ||
build_android: | ||
runs-on: ubuntu-latest | ||
needs: web_build | ||
env: | ||
GIT_SHA: ${{ needs.web_build.outputs.GIT_SHA }} | ||
steps: | ||
- name: initialize repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{env.APP_CODE_BRANCH}} | ||
lfs: true | ||
|
||
- name: Checkout parent repo if needed | ||
if: env.PARENT_DEPLOYMENT_REPO != '' | ||
uses: actions/checkout@v3 | ||
with: | ||
path: ".idems_app/deployments/${{env.PARENT_DEPLOYMENT_NAME}}" | ||
repository: ${{env.PARENT_DEPLOYMENT_REPO}} | ||
ref: ${{env.PARENT_DEPLOYMENT_BRANCH}} | ||
|
||
- name: Checkout deployment | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: ${{env.DEPLOYMENT_REPO}} | ||
path: ".idems_app/deployments/${{env.DEPLOYMENT_NAME}}" | ||
ref: "main" | ||
|
||
# - name: Checkout git lfs partial files | ||
# run: git lfs pull --include "android/*" | ||
############################################################################# | ||
# Configure | ||
# Setup node same way as web build to allow calling `npx cap sync` command | ||
############################################################################# | ||
|
||
- name: Populate google-services.json | ||
env: | ||
GOOGLE_SERVICES_JSON: ${{ env.GOOGLE_SERVICES_JSON }} | ||
run: echo $GOOGLE_SERVICES_JSON > android/app/google-services.json | ||
############################################################################# | ||
# Sync web files | ||
# Setup node same way as web build to allow calling `npx cap sync` command | ||
############################################################################# | ||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
- uses: actions/cache/restore@v3 | ||
id: cache | ||
with: | ||
path: ./.yarn/cache | ||
key: ${{ runner.os }}-node-modules-yarn-v1-${{ hashFiles('yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-node-modules-yarn-v1- | ||
- name: Install node modules | ||
run: yarn install --immutable | ||
|
||
- name: Set deployment | ||
run: yarn workflow deployment set $DEPLOYMENT_NAME | ||
|
||
- name: Populate android assets | ||
run: yarn workflow populate_android_assets | ||
|
||
- name: Update config names in android files | ||
run: | | ||
sed -i -e "s/international.idems.plh_teens/$APP_ID/g" -e "s/PLH Teens/$APP_NAME/g" ./capacitor.config.ts ./android/app/src/main/assets/capacitor.config.json ./android/app/src/main/res/values/strings.xml ./android/app/src/main/AndroidManifest.xml ./android/app/src/main/java/international/idems/plh_teens/MainActivity.java ./android/app/build.gradle | ||
- name: Add version number to build.gradle | ||
run: | | ||
# Define the path to the file | ||
FILE_PATH="./.idems_app/deployments/${{env.DEPLOYMENT_NAME}}/config.ts" | ||
# Extract the version number | ||
VERSION=$(grep 'content_tag_latest:' $FILE_PATH | sed 's/content_tag_latest: *"\(.*\)",/\1/') | ||
echo "Extracted Version: $VERSION" | ||
# Split the version into major, minor, and patch components | ||
IFS='.' read -ra VERSION_PARTS <<< "$VERSION" | ||
|
||
if [[ ${#VERSION_PARTS[@]} -ne 3 ]]; then | ||
echo "Error: Version format is not as expected." | ||
exit 1 | ||
fi | ||
|
||
# Convert minor and patch segment to 3-digit representation | ||
MINOR=$(printf "%03d" "${VERSION_PARTS[1]}") | ||
PATCH=$(printf "%03d" "${VERSION_PARTS[2]}") | ||
|
||
# Construct the new version | ||
VERSION_CODE="${VERSION_PARTS[0]}${MINOR}${PATCH}" | ||
|
||
echo "Version Code: $VERSION_CODE" | ||
echo "Version: $VERSION" | ||
|
||
sed -i -e "s/16021/$VERSION_CODE/g" -e "s/0.16.21/$VERSION/g" ./android/app/build.gradle | ||
|
||
|
||
|
||
|
||
- name: Download Build Artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: www | ||
- name: Extract Build folder | ||
run: | | ||
mkdir www | ||
tar -xf artifact.tar --directory www | ||
- name: Sync Android Files | ||
run: npx cap sync | ||
############################################################################# | ||
# Android Build | ||
############################################################################# | ||
# Java version mapping: https://stackoverflow.com/a/47457251/5693245 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: "zulu" | ||
java-version: "17" | ||
java-package: jdk | ||
cache: "gradle" | ||
- name: Setup Android SDK | ||
uses: android-actions/setup-android@v2 | ||
|
||
# Debug APK | ||
- name: Build Android Debug APK | ||
working-directory: android | ||
run: ./gradlew :app:assembleDebug | ||
|
||
- name: Upload debug apk | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: debug_apk | ||
path: android/app/build/outputs/apk/debug/app-debug.apk | ||
|
||
# Signed Release Bundle | ||
- name: Build Android Release Bundle | ||
working-directory: android | ||
run: ./gradlew :app:bundleRelease | ||
|
||
- name: Sign Android Release | ||
id: sign_aab | ||
uses: r0adkll/sign-android-release@v1 | ||
with: | ||
releaseDirectory: ./android/app/build/outputs/bundle/release | ||
signingKeyBase64: ${{ env.SIGNING_KEY }} | ||
alias: ${{ env.ALIAS }} | ||
keyStorePassword: ${{ env.KEY_STORE_PASSWORD }} | ||
keyPassword: ${{ env.KEY_PASSWORD }} | ||
|
||
- name: Upload release bundle | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: release_bundle | ||
path: ${{steps.sign_aab.outputs.signedReleaseFile}} |