Deploy app #1219
This file contains hidden or 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
| --- | |
| # Sample workflow for building and deploying a Jekyll site to GitHub Pages | |
| name: Deploy app | |
| on: | |
| 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 | |
| build_mode: | |
| description: 'Build mode:' | |
| required: true | |
| default: release | |
| type: choice | |
| options: [ release, debug ] | |
| flavor: | |
| description: 'Target flavor:' | |
| required: true | |
| default: staging | |
| type: choice | |
| options: [ development, staging, production ] | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| build_number: ${{ steps.get_build_number.outputs.build_number }} | |
| flutter_version: ${{ steps.read_flutter.outputs.flutter_version }} | |
| env: | |
| SECRET_PASSPHRASE: ${{ secrets.SECRET_PASSPHRASE }} | |
| MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} | |
| 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: Display flavor target | |
| run: echo "Flavor target is = ${{ inputs.flavor }}" | |
| - name: Check store builds with flavor | |
| run: | | |
| if [[ "${{ inputs.flavor }}" != "production" && | |
| ( "${{ 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 for 'production' flavor." | |
| exit 1 | |
| fi | |
| - name: Check build type with store builds | |
| run: | | |
| if [[ "${{ inputs.build_mode }}" != "release" && | |
| ( "${{ 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 for 'release' build type." | |
| exit 1 | |
| fi | |
| - name: Read Flutter version | |
| id: read_flutter | |
| run: echo "flutter_version=$(cat .github/configs/flutter_version)" >> $GITHUB_OUTPUT | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: ${{ steps.read_flutter.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 | |
| - name: Install Dart dependencies | |
| run: dart pub get | |
| - uses: bluefireteam/melos-action@v3 | |
| - name: Run melos analyze | |
| run: melos analyze | |
| - name: Run melos check-format | |
| run: melos check-format | |
| # 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-15 | |
| 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 | |
| - uses: maxim-lobanov/setup-xcode@v1 | |
| with: | |
| xcode-version: '16.4' | |
| - name: Show Xcode and SDKs | |
| run: | | |
| xcodebuild -version | |
| xcodebuild -showsdks | |
| xcode-select -p | |
| - 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 and build_mode values | |
| run: | | |
| echo "ios_target is set to = ${{ env.ios_target }}" | |
| echo "build_mode is set to = ${{ inputs.build_mode }}" | |
| - 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 | |
| # Rive Native setup for iOS | |
| - name: Setup rive_native for iOS | |
| run: dart run rive_native:setup --verbose --clean --platform ios | |
| - name: Display Build Number | |
| run: echo "Number is = ${{ needs.setup.outputs.build_number }}" | |
| - name: Display flavor target | |
| run: echo "Flavor target is = ${{ inputs.flavor }}" | |
| - name: Ensure jq is installed (macOS) | |
| run: | | |
| if ! command_v=$(command -v jq); then | |
| brew update | |
| brew install jq | |
| fi | |
| - name: Fetch & merge anti-phishing lists | |
| run: | | |
| curl -s https://raw.githubusercontent.com/broxus/ever-wallet-anti-phishing/master/blacklist.json \ | |
| -o /tmp/blacklist1.json | |
| curl -s https://raw.githubusercontent.com/MetaMask/eth-phishing-detect/refs/heads/main/src/config.json \ | |
| -o /tmp/config.json | |
| mkdir -p assets/configs | |
| jq -s '(.[0] + .[1].blacklist) | unique | { blacklist: . }' \ | |
| /tmp/blacklist1.json /tmp/config.json \ | |
| > assets/configs/anti_phishing.json | |
| echo "→ New anti_phishing.json:" | |
| head -n 5 assets/configs/anti_phishing.json | |
| - name: Build and deploy | |
| run: | | |
| bash scripts/build.sh \ | |
| --deploy-target ${{ env.ios_target }} \ | |
| --build-number ${{ needs.setup.outputs.build_number }} \ | |
| --flavor ${{ inputs.flavor }} \ | |
| --build-mode ${{ inputs.build_mode }} \ | |
| --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 and build_mode values | |
| run: | | |
| echo "android_target is set to = ${{ env.android_target }}" | |
| echo "build_mode is set to = ${{ inputs.build_mode }}" | |
| - 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: Display flavor target | |
| run: echo "Flavor target is = ${{ inputs.flavor }}" | |
| - name: Fetch & merge anti-phishing lists | |
| run: | | |
| curl -s https://raw.githubusercontent.com/broxus/ever-wallet-anti-phishing/master/blacklist.json \ | |
| -o /tmp/blacklist1.json | |
| curl -s https://raw.githubusercontent.com/MetaMask/eth-phishing-detect/refs/heads/main/src/config.json \ | |
| -o /tmp/config.json | |
| mkdir -p assets/configs | |
| jq -s '(.[0] + .[1].blacklist) | unique | { blacklist: . }' \ | |
| /tmp/blacklist1.json /tmp/config.json \ | |
| > assets/configs/anti_phishing.json | |
| echo "→ New anti_phishing.json:" | |
| head -n 5 assets/configs/anti_phishing.json | |
| - name: Flutter clean | |
| run: flutter clean | |
| - name: Get Flutter packages | |
| run: dart pub get | |
| - name: Build and deploy | |
| run: | | |
| bash scripts/build.sh \ | |
| --deploy-target ${{ env.android_target }} \ | |
| --build-number ${{ needs.setup.outputs.build_number }} \ | |
| --flavor ${{ inputs.flavor }} \ | |
| --build-mode ${{ inputs.build_mode }} \ | |
| --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/ |