Deploy app #629
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
name: Deploy app | |
on: | |
push: | |
branches: | |
- test | |
workflow_dispatch: | |
inputs: | |
deploy_target: | |
description: "Deploy to:" | |
required: true | |
default: "fad" | |
type: choice | |
options: | |
- "fad" | |
- "store" | |
- "ios_fad" | |
- "ios_store" | |
- "android_fad" | |
- "android_store" | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
build_number: ${{ steps.get_build_number.outputs.build_number }} | |
flutter_version: ${{ steps.set_output.outputs.flutter_version }} | |
env: | |
SECRET_PASSPHRASE: ${{ secrets.SECRET_PASSPHRASE }} | |
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} | |
FLUTTER_VERSION: '3.24.0' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Check deploy target and branch | |
run: | | |
if [[ "${{ github.ref }}" != "refs/heads/main" && | |
( "${{ inputs.deploy_target }}" == "store" || | |
"${{ inputs.deploy_target }}" == "ios_store" || | |
"${{ inputs.deploy_target }}" == "android_store" ) ]]; then | |
echo "🚫 Error: Deployment to store, ios_store, or android_store is only allowed from the 'main' branch." | |
exit 1 | |
fi | |
- name: Set output for flutter_version | |
id: set_output | |
run: | | |
echo "flutter_version=${FLUTTER_VERSION}" >> $GITHUB_OUTPUT | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
channel: 'stable' | |
cache: true | |
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} | |
- name: Install Dart dependencies | |
run: dart pub get | |
- uses: bluefireteam/melos-action@v3 | |
# Secrets | |
- name: Decrypt secrets | |
run: melos decrypt-secrets | |
- name: Get build number | |
id: get_build_number | |
run: | | |
BUILD_NUMBER=$(bash scripts/get-build-number.sh) | |
if [ -z "$BUILD_NUMBER" ]; then | |
echo "Error: Build number is not specified." | |
exit 1 | |
fi | |
echo "#️⃣ New build number: $BUILD_NUMBER" | |
echo "build_number=$BUILD_NUMBER" >> $GITHUB_OUTPUT | |
- name: Check Flutter Path | |
run: echo "Flutter path is = $FLUTTER_ROOT" | |
- name: Remove Flutter | |
run: | | |
rm -rf $FLUTTER_ROOT | |
echo "Flutter removed to free up space" | |
- name: Clean Dart dependencies | |
run: | | |
rm -rf .dart_tool/ | |
rm -rf $HOME/.pub-cache/ | |
# iOS deploy | |
ios-deploy: | |
needs: setup | |
runs-on: macos-latest | |
if: ${{ inputs.deploy_target == '' || inputs.deploy_target == 'fad' || inputs.deploy_target == 'store' || inputs.deploy_target == 'ios_fad' || inputs.deploy_target == 'ios_store' }} | |
env: | |
SECRET_PASSPHRASE: ${{ secrets.SECRET_PASSPHRASE }} | |
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Set target variable based on deploy_target | |
run: | | |
echo "deploy_target is = ${{ inputs.deploy_target }}" | |
if [[ "${{ inputs.deploy_target }}" == "" || "${{ inputs.deploy_target }}" == "fad" || "${{ inputs.deploy_target }}" = "ios_fad" ]]; then | |
echo "ios_target=ios_fad" >> $GITHUB_ENV | |
elif [[ "${{ inputs.deploy_target }}" == "store" || "${{ inputs.deploy_target }}" == "ios_store" ]]; then | |
echo "ios_target=ios_store" >> $GITHUB_ENV | |
fi | |
- name: Display ios_target value | |
run: echo "ios_target is set to = ${{ env.ios_target }}" | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ needs.setup.outputs.flutter_version }} | |
channel: 'stable' | |
cache: true | |
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} | |
- name: Display Flutter version | |
run: flutter --version | |
- uses: bluefireteam/melos-action@v3 | |
# Secrets | |
- name: Decrypt secrets | |
run: melos decrypt-secrets | |
# iOS certs | |
- name: Making sure the iOS certificates and profiles are installed | |
run: melos build:ios_match_assure | |
# Dart/Flutter | |
- name: Generate dart code | |
run: melos codegen --no-select | |
- name: Display Build Number | |
run: | |
echo "Number is = ${{ needs.setup.outputs.build_number }}" | |
- name: Build and deploy | |
run: | | |
bash scripts/build.sh \ | |
--deploy-target ${{ env.ios_target }} \ | |
--build-number ${{ needs.setup.outputs.build_number }} \ | |
--upload true | |
- name: Clean Xcode Derived Data | |
run: | | |
rm -rf ~/Library/Developer/Xcode/DerivedData | |
- name: Clean CocoaPods cache | |
run: | | |
pod cache clean --all | |
rm -rf ios/Pods | |
rm -rf ios/Podfile.lock | |
- name: Remove Flutter | |
run: | | |
rm -rf $FLUTTER_ROOT | |
- name: Clean Dart dependencies | |
run: | | |
rm -rf .dart_tool/ | |
rm -rf $HOME/.pub-cache/ | |
# Android deploy | |
android-deploy: | |
needs: setup | |
runs-on: ubuntu-latest | |
if: ${{ inputs.deploy_target == '' || inputs.deploy_target == 'fad' || inputs.deploy_target == 'store' || inputs.deploy_target == 'android_fad' || inputs.deploy_target == 'android_store' }} | |
env: | |
SECRET_PASSPHRASE: ${{ secrets.SECRET_PASSPHRASE }} | |
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} | |
steps: | |
- name: Reinstall existing fastlane plugin | |
run: | | |
sudo gem uninstall fastlane-plugin-firebase_app_distribution | |
gem install fastlane-plugin-firebase_app_distribution --user-install | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Set target variable based on deploy_target | |
run: | | |
echo "deploy_target is = ${{ inputs.deploy_target }}" | |
if [[ "${{ inputs.deploy_target }}" == "" || "${{ inputs.deploy_target }}" == "fad" || "${{ inputs.deploy_target }}" = "android_fad" ]]; then | |
echo "android_target=android_fad" >> $GITHUB_ENV | |
elif [[ "${{ inputs.deploy_target }}" == "store" || "${{ inputs.deploy_target }}" == "android_store" ]]; then | |
echo "android_target=android_store" >> $GITHUB_ENV | |
fi | |
- name: Display android_target value | |
run: echo "android_target is set to = ${{ env.android_target }}" | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ needs.setup.outputs.flutter_version }} | |
channel: 'stable' | |
cache: true | |
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} | |
- name: Display Flutter version | |
run: flutter --version | |
- uses: bluefireteam/melos-action@v3 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: zulu | |
java-version: "17.x" | |
# Secrets | |
- name: Decrypt secrets | |
run: melos decrypt-secrets | |
# Dart/Flutter | |
- name: Generate dart code | |
run: melos codegen --no-select | |
- name: Display Build Number | |
run: | |
echo "Number is = ${{ needs.setup.outputs.build_number }}" | |
- name: Build and deploy | |
run: | | |
bash scripts/build.sh \ | |
--deploy-target ${{ env.android_target }} \ | |
--build-number ${{ needs.setup.outputs.build_number }} \ | |
--upload true | |
- name: Remove Flutter | |
run: | | |
rm -rf $FLUTTER_ROOT | |
echo "Flutter removed to free up space" | |
- name: Clean Dart dependencies | |
run: | | |
rm -rf .dart_tool/ | |
rm -rf $HOME/.pub-cache/ |