Skip to content

v3.0.0

v3.0.0 #60

# Create production builds for web, ios and android, and deploy to relevant providers
name: Build and Deploy Production
on:
release:
types: [published]
jobs:
build_dist:
name: Build Production
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
# TODO - consider gradle/swift caches as well - https://github.com/actions/cache/blob/main/examples.md#java---gradle
- name: Setup Cache
uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn install
- name: Populate Config
run: echo $FIREBASE_CONFIG_JSON > maths-club-app/src/environments/firebaseConfig.json
env:
FIREBASE_CONFIG_JSON: ${{secrets.FIREBASE_CONFIG_JSON}}
- name: Build and Copy
run: cd maths-club-app && npm run build
# Store various folders as artifacts for use by other jobs (ignore node modules except those needed by capacitor)
- name: Store Build Artifact
uses: actions/upload-artifact@v2
with:
name: maths-club-app
# save maths-club-app main folder alongside capacitor community modules (cli installed later)
path: |
maths-club-app
!maths-club-app/node_modules
deploy_web:
needs: [build_dist]
name: Deploy to Firebase Production
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Download Build Artifact
uses: actions/download-artifact@v2
with:
name: maths-club-app
- name: Deploy to Firebase
continue-on-error: true
uses: w9jds/firebase-action@master
with:
args: deploy
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
build_deploy_android:
needs: [build_dist]
name: Deploy to Play Store Internal Track
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Download Build Artifact
uses: actions/download-artifact@v2
with:
name: maths-club-app
- name: Setup Cache
uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn install --silent
- name: Sync capacitor plugins
run: npx cap sync android
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
# use data stored in secretes to populate google-services.json
- name: Write Google Services Json
run: echo $GOOGLE_SERVICES_JSON > android/app/google-services.json
env:
GOOGLE_SERVICES_JSON: ${{secrets.GOOGLE_SERVICES_JSON}}
- name: Generate Android Build
# create release app bundle (aab) and app assemble (apk)
run: cd android && chmod +x ./gradlew && ./gradlew clean :app:bundleRelease :app:assembleRelease
- name: Sign Android Bundle
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: android/app/build/outputs/bundle/release
signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY_BASE64 }}
alias: ${{ secrets.ANDROID_KEY_ALIAS }}
keyStorePassword: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}
- name: Upload to Google play
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
packageName: io.c2dev.samimathsclub
releaseFile: ${{ env.SIGNED_RELEASE_FILE}}
track: internal
#whatsNewDirectory: /distribution/whatsnew
build_deploy_ios:
needs: [build_dist]
name: Deploy to IOS Testflight
runs-on: macos-latest
steps:
- name: Download Build Artifact
uses: actions/download-artifact@v2
with:
name: maths-club-app
- name: Setup Cache
uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn install --silent
- name: Sync capacitor plugins
run: npx cap sync ios
- name: Setup environment
run: |
cd ios/App
echo $MOBILEPROVISION_BASE64 | base64 --decode > ios-build.mobileprovision
echo $GOOGLE_SERVICES_PLIST_BASE64 | base64 --decode > App/GoogleService-Info.plist
env:
MOBILEPROVISION_BASE64: ${{secrets.IOS_PROVISION_BASE64}}
GOOGLE_SERVICES_PLIST_BASE64: ${{secrets.GOOGLE_SERVICES_PLIST_BASE64}}
- name: Install Dependencies
run: |
cd ios/App
sudo gem install bundler && sudo gem install cocoapods && sudo bundle install && pod install
- name: Run fastlane
run: |
cd ios/App
bundle exec fastlane ios ci_beta --verbose
env:
# created when first initialising match certs
MATCH_PASSWORD: ${{secrets.FASTFILE_MATCH_PASSWORD}}
# apple account pw, used to generate/refresh/verify certs
# should match app manager username (as specified in fastfile), not main account holder
FASTLANE_PASSWORD: ${{secrets.IOS_DEVACCOUNT_PW}}
# basic auth creds: "git_username:git_personal_access_token_for_match_repo"
FASTLANE_MATCH_GITHUB_AUTH: ${{secrets.FASTLANE_MATCH_GITHUB_AUTH}}
# Generated from appleid.apple.com/account/manage (login to avoid 2fa)
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD}}
# TODO - could also consider publishing to appetize or similar
# NOTE - would require building debug apk/ipa
# NOTE - could be called from another workflow via https://github.com/marketplace/actions/workflow-dispatch
# NOTE - could persist apk/ipa across workflows via https://jfrog.com/artifactory
cleanup:
# NOTE - this will only run if previous action successful, so either ensure passes, or move to cron job
needs: [build_deploy_ios]
runs-on: ubuntu-latest
name: Delete intermediary artifacts
steps:
- uses: geekyeggo/delete-artifact@v1
with:
name: maths-club-app
failOnError: false