diff --git a/.github/wiki/Deployment.md b/.github/wiki/Deployment.md index 7465ba72..96a244d6 100644 --- a/.github/wiki/Deployment.md +++ b/.github/wiki/Deployment.md @@ -1,19 +1,37 @@ # Deployment Process +## For Android + +### Guide + +- Before publishing the Android application, we have to prepare the necessary credentials and information: + - A Play Store developer account. + - Your application's app id. This could be multiple bundle ids according to the number of application’s flavors. + - A new app on Play Store. + +- Add these variables as the secrets of CI: + - **ENV_PRODUCTION**: the production .env configuration file content. + - **GOOGLE_PLAY_SERVICE_ACCOUNT_JSON**: the json file content of the Play Store's Service Account for app publishing. Please check out [how to create the Service Account](https://support.staffbase.com/hc/en-us/articles/360018569579-Preparing-Automated-Publishing-for-Google-Play-Store). + +### Resources + +- [Build and release an Android app](https://docs.flutter.dev/deployment/android#build-an-apk). +- [Preparing Automated Publishing for Google Play Store](https://support.staffbase.com/hc/en-us/articles/360018569579-Preparing-Automated-Publishing-for-Google-Play-Store). + ## For iOS ### Guide -- Before deploying the iOS application, we have to prepare the necessary credentials and information: +- Before publishing the iOS application, we have to prepare the necessary credentials and information: - An Apple developer account. - Your application’s bundle id. This could be multiple bundle ids according to the number of application’s flavors. - - A new app's on Apple Store Connect that links to the bundle id. + - A new app on Apple Store Connect that links to the bundle id. - The access to Git’s [Match repository](https://codesigning.guide/). -- Create certificates for distribution and [code signing](https://codesigning.guide/) so we are able to fetch the certificates through [Match](https://docs.fastlane.tools/actions/match/). -- Setup [Fastlane](https://docs.fastlane.tools/getting-started/ios/setup/) and [Match](https://docs.fastlane.tools/actions/match/). -- Adding these variables as the environment variable of CI: +- Create certificates for distribution and [code signing](https://codesigning.guide/) so we are able to fetch the certificates through the [Match](https://docs.fastlane.tools/actions/match/) repository. +- Set up [Fastlane](https://docs.fastlane.tools/getting-started/ios/setup/) and [Match](https://docs.fastlane.tools/actions/match/). +- Add these variables as the secrets of CI: - **FASTLANE_USER**: This will be referred to in `Appfile` and `Fastfile`. Set your Apple ID to this variable. - **FASTLANE_PASSWORD**: This variable will be referred to internally in Fastlane. Set the password of your Apple ID to this variable. @@ -23,10 +41,10 @@ - **KEYCHAIN_PASSWORD**: We can create a keychain password for ourself and it could be anything. - **SSH_PRIVATE_KEY**: In order to fetch the distribution files from Git’s [Match repository](https://codesigning.guide/), we have to generate an SSH key and save it as the environment variable in CI. -- Run the corresponding workflows CI or `fastlane` commands and enjoy the result! +- Run the corresponding workflows or `fastlane` commands and enjoy the result! -### Resource +### Resources - [https://medium.com/flutter-community/deploying-flutter-ios-apps-with-fastlane-and-github-actions-2e87465e056e](https://medium.com/flutter-community/deploying-flutter-ios-apps-with-fastlane-and-github-actions-2e87465e056e) - [https://docs.flutter.dev/deployment/cd](https://docs.flutter.dev/deployment/cd) -- [https://jaysavsani07.medium.com/flutter-ci-cd-with-github-actions-fastlane-part-2-ios-a4b281921d39](https://jaysavsani07.medium.com/flutter-ci-cd-with-github-actions-fastlane-part-2-ios-a4b281921d39) \ No newline at end of file +- [https://jaysavsani07.medium.com/flutter-ci-cd-with-github-actions-fastlane-part-2-ios-a4b281921d39](https://jaysavsani07.medium.com/flutter-ci-cd-with-github-actions-fastlane-part-2-ios-a4b281921d39) diff --git a/.github/workflows/android_deploy_production.yml b/.github/workflows/android_deploy_production.yml index 297e95a4..7173c2b0 100644 --- a/.github/workflows/android_deploy_production.yml +++ b/.github/workflows/android_deploy_production.yml @@ -9,10 +9,12 @@ jobs: build_and_deploy_android: name: Build & Deploy Android runs-on: ubuntu-latest + timeout-minutes: 30 steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - - name: Setup Python + - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.9' @@ -20,25 +22,25 @@ jobs: - name: Generate new project run: make run PACKAGE_NAME=co.nimblehq.flutter.template PROJECT_NAME=flutter_templates APP_NAME="Flutter Templates" - - name: Setup Java JDK + - name: Set up Java JDK uses: actions/setup-java@v3 with: distribution: 'adopt' java-version: '11' - - name: Setup Flutter environment + - name: Set up Flutter environment uses: subosito/flutter-action@v2 with: channel: 'stable' flutter-version: '3.3.10' - - name: Get flutter dependencies + - name: Get Flutter dependencies run: flutter pub get - - name: Run code generator. + - name: Run code generator run: flutter packages pub run build_runner build --delete-conflicting-outputs - - name: Setup .env + - name: Set up .env env: ENV_PRODUCTION: ${{ secrets.ENV_PRODUCTION }} run: | diff --git a/.github/workflows/android_deploy_production_to_playstore.yml b/.github/workflows/android_deploy_production_to_playstore.yml new file mode 100644 index 00000000..7381ec1d --- /dev/null +++ b/.github/workflows/android_deploy_production_to_playstore.yml @@ -0,0 +1,62 @@ +name: Android - Deploy Production build to Play Store + +on: + push: + branches: + - main + +jobs: + build_and_deploy_android: + name: Build & Deploy Android + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.9' + + - name: Generate new project + run: make run PACKAGE_NAME=co.nimblehq.flutter.template PROJECT_NAME=flutter_templates APP_NAME="Flutter Templates" + + - name: Set up Java JDK + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '11' + + - name: Set up Flutter environment + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + flutter-version: '3.3.10' + + - name: Get Flutter dependencies + run: flutter pub get + + - name: Run code generator + run: flutter packages pub run build_runner build --delete-conflicting-outputs + + - name: Set up .env + env: + ENV_PRODUCTION: ${{ secrets.ENV_PRODUCTION }} + run: | + echo $ENV_PRODUCTION > .env + + - name: Build Production App Bundle + run: flutter build appbundle --flavor production --release --build-number $GITHUB_RUN_NUMBER + + # TODO We will enable this step later when having a shared Service Account on our organization + # Basically, this step will work properly after providing a valid Service Account. + # - name: Upload Android Production Release bundle to Play Store + # uses: r0adkll/upload-google-play@v1 + # with: + # serviceAccountJson: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }} + # packageName: co.nimblehq.flutter.template + # releaseFile: build/app/outputs/bundle/productionRelease/app-production-release.aab + # track: internal + # userFraction: 1.0 + # whatsNewDirectory: .github/workflows/whatsnew diff --git a/.github/workflows/android_deploy_staging.yml b/.github/workflows/android_deploy_staging.yml index 54cdc2e4..05939515 100644 --- a/.github/workflows/android_deploy_staging.yml +++ b/.github/workflows/android_deploy_staging.yml @@ -9,11 +9,13 @@ jobs: build_and_deploy_android: name: Build & Deploy Android runs-on: ubuntu-latest + timeout-minutes: 30 environment: staging steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - - name: Setup Python + - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.9' @@ -21,25 +23,25 @@ jobs: - name: Generate new project run: make run PACKAGE_NAME=co.nimblehq.flutter.template PROJECT_NAME=flutter_templates APP_NAME="Flutter Templates" - - name: Setup Java JDK + - name: Set up Java JDK uses: actions/setup-java@v3 with: distribution: 'adopt' java-version: '11' - - name: Setup Flutter environment + - name: Set up Flutter environment uses: subosito/flutter-action@v2 with: channel: 'stable' flutter-version: '3.3.10' - - name: Get flutter dependencies + - name: Get Flutter dependencies run: flutter pub get - - name: Run code generator. + - name: Run code generator run: flutter packages pub run build_runner build --delete-conflicting-outputs - - name: Setup .env.staging + - name: Set up .env.staging env: ENV_STAGING: ${{ secrets.ENV_STAGING }} run: | diff --git a/.github/workflows/bump_version.yml b/.github/workflows/bump_version.yml index 5ea2fb77..c9cfcd6d 100644 --- a/.github/workflows/bump_version.yml +++ b/.github/workflows/bump_version.yml @@ -12,6 +12,7 @@ jobs: bump_version: name: Bump version runs-on: ubuntu-latest + timeout-minutes: 5 steps: - name: Checkout the latest code uses: actions/checkout@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 24ebb680..89125119 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,10 +14,11 @@ jobs: test: name: Template initializing scripts test runs-on: ubuntu-latest + timeout-minutes: 30 steps: - uses: actions/checkout@v2.3.2 - - name: Setup Python + - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.9' @@ -25,23 +26,23 @@ jobs: - name: Generate new project run: make run PACKAGE_NAME=co.nimblehq.flutter.template PROJECT_NAME=flutter_templates APP_NAME="Flutter Templates" - - name: Setup Flutter environment + - name: Set up Flutter environment uses: subosito/flutter-action@v2 with: channel: 'stable' flutter-version: '3.3.10' - - name: Get flutter dependencies. + - name: Get Flutter dependencies run: flutter pub get - name: Run code generator run: flutter packages pub run build_runner build --delete-conflicting-outputs - - name: Check for any formatting issues in the code. + - name: Check for any formatting issues in the code run: flutter format --set-exit-if-changed . - - name: Statically analyze the Dart code for any errors. + - name: Statically analyze the Dart code for any errors run: flutter analyze . - - name: Run widget tests, unit tests. + - name: Run widget tests, unit tests run: flutter test --machine --coverage diff --git a/template/.github/workflows/android_deploy_production.yml b/template/.github/workflows/android_deploy_production.yml index 95276223..e857d713 100644 --- a/template/.github/workflows/android_deploy_production.yml +++ b/template/.github/workflows/android_deploy_production.yml @@ -9,28 +9,30 @@ jobs: build_and_deploy_android: name: Build & Deploy Android runs-on: ubuntu-latest + timeout-minutes: 30 steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - - name: Setup Java JDK + - name: Set up Java JDK uses: actions/setup-java@v3 with: distribution: 'adopt' java-version: '11' - - name: Setup Flutter environment + - name: Set up Flutter environment uses: subosito/flutter-action@v2 with: channel: 'stable' flutter-version: '3.3.10' - - name: Get flutter dependencies + - name: Get Flutter dependencies run: flutter pub get - - name: Run code generator. + - name: Run code generator run: flutter packages pub run build_runner build --delete-conflicting-outputs - - name: Setup .env + - name: Set up .env env: ENV_PRODUCTION: ${{ secrets.ENV_PRODUCTION }} run: | diff --git a/template/.github/workflows/android_deploy_production_to_playstore.yml b/template/.github/workflows/android_deploy_production_to_playstore.yml new file mode 100644 index 00000000..d07ca14b --- /dev/null +++ b/template/.github/workflows/android_deploy_production_to_playstore.yml @@ -0,0 +1,52 @@ +name: Android - Deploy Production build to Play Store + +on: + push: + branches: + - main + +jobs: + build_and_deploy_android: + name: Build & Deploy Android + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Java JDK + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '11' + + - name: Set up Flutter environment + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + flutter-version: '3.3.10' + + - name: Get Flutter dependencies + run: flutter pub get + + - name: Run code generator + run: flutter packages pub run build_runner build --delete-conflicting-outputs + + - name: Set up .env + env: + ENV_PRODUCTION: ${{ secrets.ENV_PRODUCTION }} + run: | + echo $ENV_PRODUCTION > .env + + - name: Build Production App Bundle + run: flutter build appbundle --flavor production --release --build-number $GITHUB_RUN_NUMBER + + - name: Upload Android Production Release bundle to Play Store + uses: r0adkll/upload-google-play@v1 + with: + serviceAccountJson: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }} + packageName: co.nimblehq.flutter.template + releaseFile: build/app/outputs/bundle/productionRelease/app-production-release.aab + track: internal + userFraction: 1.0 + whatsNewDirectory: .github/workflows/whatsnew diff --git a/template/.github/workflows/android_deploy_staging.yml b/template/.github/workflows/android_deploy_staging.yml index 1dcb514d..70e1f42d 100644 --- a/template/.github/workflows/android_deploy_staging.yml +++ b/template/.github/workflows/android_deploy_staging.yml @@ -9,28 +9,30 @@ jobs: build_and_deploy_android: name: Build & Deploy Android runs-on: ubuntu-latest + timeout-minutes: 30 steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - - name: Setup Java JDK + - name: Set up Java JDK uses: actions/setup-java@v3 with: distribution: 'adopt' java-version: '11' - - name: Setup Flutter environment + - name: Set up Flutter environment uses: subosito/flutter-action@v2 with: channel: 'stable' flutter-version: '3.3.10' - - name: Get flutter dependencies + - name: Get Flutter dependencies run: flutter pub get - - name: Run code generator. + - name: Run code generator run: flutter packages pub run build_runner build --delete-conflicting-outputs - - name: Setup .env.staging + - name: Set up .env.staging env: ENV_STAGING: ${{ secrets.ENV_STAGING }} run: | diff --git a/template/.github/workflows/bump_version.yml b/template/.github/workflows/bump_version.yml index 737d76ee..2a91fce4 100644 --- a/template/.github/workflows/bump_version.yml +++ b/template/.github/workflows/bump_version.yml @@ -12,6 +12,7 @@ jobs: bump_version: name: Bump version runs-on: ubuntu-latest + timeout-minutes: 5 steps: - name: Checkout the latest code uses: actions/checkout@v3 diff --git a/template/.github/workflows/ios_deploy_to_app_store.yml b/template/.github/workflows/ios_deploy_to_app_store.yml index c16f847f..7e4582aa 100644 --- a/template/.github/workflows/ios_deploy_to_app_store.yml +++ b/template/.github/workflows/ios_deploy_to_app_store.yml @@ -9,6 +9,7 @@ jobs: build_and_upload_to_app_store: name: Build And Upload iOS Application To AppStore runs-on: macOS-latest + timeout-minutes: 30 defaults: run: working-directory: template @@ -28,13 +29,13 @@ jobs: with: ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - name: Setup Flutter environment + - name: Set up Flutter environment uses: subosito/flutter-action@v2 with: channel: 'stable' flutter-version: '3.3.10' - - name: Get flutter dependencies + - name: Get Flutter dependencies run: flutter pub get - name: Run code generator diff --git a/template/.github/workflows/ios_deploy_to_testflight.yml b/template/.github/workflows/ios_deploy_to_testflight.yml index 15e2d985..04dcb757 100644 --- a/template/.github/workflows/ios_deploy_to_testflight.yml +++ b/template/.github/workflows/ios_deploy_to_testflight.yml @@ -9,6 +9,7 @@ jobs: build_and_upload_to_testflight: name: Build And Upload iOS Application To TestFlight runs-on: macOS-latest + timeout-minutes: 30 env: TEAM_ID: ${{ secrets.TEAM_ID }} FASTLANE_USER: ${{ secrets.FASTLANE_USER }} @@ -25,13 +26,13 @@ jobs: with: ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - name: Setup Flutter environment + - name: Set up Flutter environment uses: subosito/flutter-action@v2 with: channel: 'stable' flutter-version: '3.3.10' - - name: Get flutter dependencies + - name: Get Flutter dependencies run: flutter pub get - name: Run code generator diff --git a/template/.github/workflows/test.yml b/template/.github/workflows/test.yml index bd27098d..3bc45d98 100644 --- a/template/.github/workflows/test.yml +++ b/template/.github/workflows/test.yml @@ -12,29 +12,30 @@ jobs: lint_and_test: name: Static code analyze & Unit test runs-on: ubuntu-latest + timeout-minutes: 30 environment: staging steps: - uses: actions/checkout@v2.3.2 - - name: Setup Flutter environment + - name: Set up Flutter environment uses: subosito/flutter-action@v2 with: channel: 'stable' flutter-version: '3.3.10' - - name: Get flutter dependencies. + - name: Get Flutter dependencies run: flutter pub get - name: Run code generator run: flutter packages pub run build_runner build --delete-conflicting-outputs - - name: Check for any formatting issues in the code. + - name: Check for any formatting issues in the code run: flutter format --set-exit-if-changed . - - name: Statically analyze the Dart code for any errors. + - name: Statically analyze the Dart code for any errors run: flutter analyze . - - name: Run widget tests, unit tests. + - name: Run widget tests, unit tests run: flutter test --machine --coverage - name: Upload coverage to codecov diff --git a/template/.github/workflows/whatsnew/whatsnew-en-US b/template/.github/workflows/whatsnew/whatsnew-en-US new file mode 100644 index 00000000..6230febe --- /dev/null +++ b/template/.github/workflows/whatsnew/whatsnew-en-US @@ -0,0 +1,3 @@ + +Enter or paste your release notes for en-US here +