Skip to content

Commit

Permalink
chore(ci): abstract out build and deployment actions
Browse files Browse the repository at this point in the history
  • Loading branch information
JagandeepBrar committed Apr 3, 2022
1 parent 40fc48a commit 84578a6
Show file tree
Hide file tree
Showing 11 changed files with 365 additions and 378 deletions.
135 changes: 135 additions & 0 deletions .github/actions/prepare_for_build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: 'Prepare for Build'
description: 'Setup all required dependencies and secrets for building the given platform'

inputs:
platform:
description: 'Platform to be Built'
required: true

# Secret Keys
android-key-jks:
description: 'Android Signing Key'
required: false
default: ''
android-key-properties:
description: 'Android Signing Key Properties'
required: false
default: ''
appstore-connect-key:
description: 'App Store Connect API Key'
required: false
default: ''
firebase-options:
description: 'Firebase Configuration'
required: false
default: ''
google-play-key:
description: 'Google Play Store API Key'
required: false
default: ''
match-ssh-private-key:
description: 'Fastlane Match SSH Key'
required: false
default: ''

runs:
using: composite
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Prepare Core
uses: actions/download-artifact@v3
with:
name: core-files

- name: Prepare Folders
shell: bash
run: |
mkdir -p output
mkdir -p keys
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true

- name: Install Java
if: ${{ inputs.platform == 'android' }}
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 11

- name: Install Ruby
if: ${{ inputs.platform == 'android' || inputs.platform == 'ios' || inputs.platform == 'macos' }}
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Install XCode
if: ${{ inputs.platform == 'ios' || inputs.platform == 'macos' }}
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Setup Match SSH Keys
if: ${{ inputs.platform == 'ios' || inputs.platform == 'macos' }}
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ inputs.match-ssh-private-key }}

- name: Setup Secret Keys
shell: bash
run: |
echo ${{ inputs.appstore-connect-key }} | base64 --decode > keys/appstore.p8
echo ${{ inputs.google-play-key }} | base64 --decode > keys/googleplay.json
echo ${{ inputs.android-key-jks }} | base64 --decode > android/key.jks
echo ${{ inputs.android-key-properties }} | base64 --decode > android/key.properties
echo ${{ inputs.firebase-options }} | base64 --decode > lib/firebase_options.dart
- name: Setup Android Platform
if: ${{ inputs.platform == 'android' }}
shell: bash
run: |
flutter pub get
(cd android && bundle install)
- name: Setup iOS Platform
if: ${{ inputs.platform == 'ios' }}
shell: bash
run: |
flutter pub get
(cd ios && pod install --repo-update)
(cd ios && bundle install)
- name: Setup Linux Platform
if: ${{ inputs.platform == 'linux' }}
shell: bash
run: |
flutter config --enable-linux-desktop
flutter pub get
- name: Setup macOS Platform
if: ${{ inputs.platform == 'macos' }}
shell: bash
run: |
flutter config --enable-macos-desktop
flutter pub get
(cd macos && pod install --repo-update)
(cd macos && bundle install)
- name: Setup Web Platform
if: ${{ inputs.platform == 'web' }}
shell: bash
run: |
flutter pub get
- name: Setup Test Platform
if: ${{ inputs.platform == 'test' }}
shell: bash
run: |
flutter pub get
77 changes: 77 additions & 0 deletions .github/actions/prepare_for_deployment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: 'Prepare for Deployment'
description: 'Setup all required dependencies and secrets for the given release channel'

inputs:
channel:
description: 'Release Channel'
required: true

# Secret Keys
appstore-connect-key:
description: 'App Store Connect API Key'
required: false
default: ''
google-play-key:
description: 'Google Play Store API Key'
required: false
default: ''
snapcraft-token:
description: 'Snapcraft API Key'
required: false
default: ''

runs:
using: composite
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Prepare Folders
shell: bash
run: |
mkdir -p output
mkdir -p keys
- name: Install Ruby
if: ${{ inputs.channel == 'play-store' || inputs.channel == 'app-store' }}
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Install Snapcraft
if: ${{ inputs.channel == 'snapcraft' }}
uses: samuelmeuli/action-snapcraft@v1
with:
snapcraft_token: ${{ inputs.snapcraft-token }}

- name: Install XCode
if: ${{ inputs.channel == 'app-store' }}
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Setup Secret Keys
shell: bash
run: |
echo ${{ inputs.appstore-connect-key }} | base64 --decode > keys/appstore.p8
echo ${{ inputs.google-play-key }} | base64 --decode > keys/googleplay.json
- name: Setup Android Platform
if: ${{ inputs.channel == 'play-store' }}
shell: bash
run: |
cd android && bundle install
- name: Setup iOS Platform
if: ${{ inputs.channel == 'app-store' }}
shell: bash
run: |
cd ios && bundle install
- name: Setup macOS Platform
if: ${{ inputs.channel == 'app-store' }}
shell: bash
run: |
cd macos && bundle install
90 changes: 17 additions & 73 deletions .github/workflows/build_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: 'Build Android'
on:
workflow_call:
inputs:
build_number:
build-number:
required: true
type: string

Expand All @@ -16,99 +16,43 @@ on:
required: true

jobs:
build_playstore_package:
build-playstore-package:
name: Play Store Package
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup Environment
uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master
with:
fetch-depth: 0

- name: Install Core Files
uses: actions/download-artifact@v3
with:
name: core_files

- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Install Java
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 11

- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
cache-key: ${{ github.sha }}
platform: android
android-key-jks: ${{ secrets.KEY_JKS }}
android-key-properties: ${{ secrets.KEY_PROPERTIES }}
firebase-options: ${{ secrets.FIREBASE_OPTIONS }}

- name: Build LunaSea
working-directory: ${{ github.workspace }}/android
env:
SUPPLY_JSON_KEY: ${{ github.workspace }}/.fastlane-android-auth.json
run: |
echo ${{ secrets.FIREBASE_OPTIONS }} | base64 --decode > ../lib/firebase_options.dart
echo ${{ secrets.KEY_JKS }} | base64 --decode > ../android/key.jks
echo ${{ secrets.KEY_PROPERTIES }} | base64 --decode > ../android/key.properties
flutter pub get
bundle install
bundle exec fastlane build_aab build_number:${{ inputs.build_number }}
run: bundle exec fastlane build_aab build-number:${{ inputs.build-number }}

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: android-playstore-package
path: ${{ github.workspace }}/output

build_app_package:
build-app-package:
name: App Package
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install Core Files
uses: actions/download-artifact@v3
with:
name: core_files

- name: Install Ruby
uses: ruby/setup-ruby@v1
- name: Setup Environment
uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master
with:
bundler-cache: true
platform: android
android-key-jks: ${{ secrets.KEY_JKS }}
android-key-properties: ${{ secrets.KEY_PROPERTIES }}
firebase-options: ${{ secrets.FIREBASE_OPTIONS }}

- name: Install Java
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 11

- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
cache-key: ${{ github.sha }}

- name: Build LunaSea
working-directory: ${{ github.workspace }}/android
env:
SUPPLY_JSON_KEY: ${{ github.workspace }}/.fastlane-android-auth.json
run: |
echo ${{ secrets.FIREBASE_OPTIONS }} | base64 --decode > ../lib/firebase_options.dart
echo ${{ secrets.KEY_JKS }} | base64 --decode > ../android/key.jks
echo ${{ secrets.KEY_PROPERTIES }} | base64 --decode > ../android/key.properties
flutter pub get
bundle install
bundle exec fastlane build_apk build_number:${{ inputs.build_number }}
run: bundle exec fastlane build_apk build_number:${{ inputs.build-number }}

- name: Upload Artifact
uses: actions/upload-artifact@v3
Expand Down
Loading

0 comments on commit 84578a6

Please sign in to comment.