diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..fb993699 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,78 @@ +name: Build & Test + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: macos-latest + + steps: + - uses: actions/checkout@v3 + + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: "3.13.5" + channel: "stable" + + - name: Install dependencies + run: flutter pub get + + - name: Flutter analyze + run: flutter analyze + + # Your project will need to have tests in test/ and a dependency on + # package:test for this step to succeed. + - name: Run tests + run: flutter test --coverage + + - uses: codecov/codecov-action@v3 + with: + files: coverage/lcov.info + verbose: true + + + # Continuous Deployment to Fly.io + # https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ + # flutter_deploy: + # name: Deploy Flutter app + # runs-on: ubuntu-latest +# + # needs: [build] + # # https://stackoverflow.com/questions/58139406/only-run-job-on-specific-branch-with-github-actions + # if: github.ref == 'refs/heads/main' + # env: + # FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} + # steps: + # - uses: actions/checkout@v3 +# + # - name: Install Flutter + # uses: subosito/flutter-action@v2 + # with: + # channel: 'stable' +# + # # Your project will need to have tests in test/ and a dependency on + # # package:test for this step to succeed. Note that Flutter projects will + # # want to change this to 'flutter test'. + # - name: Check build + # run: flutter analyze +# + # - name: Create release build + # # github.com/dwyl/app/issues/315#issuecomment-1443747737 + # run: flutter build web --release --web-renderer html + # +# + # # See https://github.com/dwyl/app/issues/326. + # # This will fetch files concurrently needed for the app and not wait for `flutter.js` to load + # - name: Run post-build script to download files concurrently + # run: | + # chmod +x ./build_tools/patch_web.sh + # sh ./build_tools/patch_web.sh --ignore-whitespace +# + # - uses: superfly/flyctl-actions@1.1 + # with: + # args: "deploy" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index ed8021b2..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: build - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - build: - runs-on: macos-latest - - steps: - - uses: actions/checkout@v3 - - # Installing Flutter because it's easier to generate .lcov files for test coverage - - name: Install Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - - - name: Install dependencies - run: flutter pub get - - - name: Flutter analyze - run: flutter analyze - - # Your project will need to have tests in test/ and a dependency on - # package:test for this step to succeed. Note that Flutter projects will - # want to change this to 'flutter test'. - - name: Run tests - run: flutter test --coverage - - - uses: codecov/codecov-action@v3 - with: - files: coverage/lcov.info - verbose: true # optional (default = false) - - - # Continuous Deployment to Fly.io - # https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ - flutter_deploy: - name: Deploy Flutter app - runs-on: ubuntu-latest - - needs: [build] - # https://stackoverflow.com/questions/58139406/only-run-job-on-specific-branch-with-github-actions - if: github.ref == 'refs/heads/main' - env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} - steps: - - uses: actions/checkout@v3 - - - name: Install Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - - # Your project will need to have tests in test/ and a dependency on - # package:test for this step to succeed. Note that Flutter projects will - # want to change this to 'flutter test'. - - name: Check build - run: flutter analyze - - - name: Create release build - # github.com/dwyl/app/issues/315#issuecomment-1443747737 - run: flutter build web --release --web-renderer html - - - # See https://github.com/dwyl/app/issues/326. - # This will fetch files concurrently needed for the app and not wait for `flutter.js` to load - - name: Run post-build script to download files concurrently - run: | - chmod +x ./build_tools/patch_web.sh - sh ./build_tools/patch_web.sh --ignore-whitespace - - - uses: superfly/flyctl-actions@1.1 - with: - args: "deploy" \ No newline at end of file diff --git a/.github/workflows/deploy_android.yml b/.github/workflows/deploy_android.yml new file mode 100644 index 00000000..0d346534 --- /dev/null +++ b/.github/workflows/deploy_android.yml @@ -0,0 +1,86 @@ +name: Deploy Android (Google Play Store) +on: + # Only trigger, when the "build" workflow succeeded (only works in the Master Branch) + workflow_run: + workflows: ["Build & Test"] + types: + - completed + + # Only trigger, when pushing into the `main` branch + push: + branches: [main] + + # DELETE THIS + #pull_request: + # branches: [ "main" ] + +permissions: + contents: write + +jobs: + build-and-deploy_android: + runs-on: ubuntu-latest + + steps: + - name: ⬇️ Checkout code + uses: actions/checkout@v3 + + # Needed to base64 decode the upload keystore + - name: βš™οΈ Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: "12.x" + cache: 'gradle' + id: java + + # Needed to run Flutter-based commands + - name: 🐦 Install Flutter + uses: subosito/flutter-action@v2 + with: + # If the flutter version that is used in development increases, it's recommended this one increases as well + flutter-version: "3.13.5" + channel: "stable" + + - name: πŸ“š Install dependencies + run: flutter pub get + + - name: πŸ”’ Retrieve base64 keystore and decode it to a file + env: + KEYSTORE_BASE64: ${{ secrets.KEYSTORE_FILE_BASE64 }} + run: echo $KEYSTORE_BASE64 | base64 --decode > "${{ github.workspace }}/decoded_android-keystore.jks" + + # Creates keystore file. + # Needs to be the same as the one defined in `android/app/build.gradle` + - name: πŸ“πŸ” Create key.properties file + env: + KEYSTORE_PROPERTIES_PATH: ${{ github.workspace }}/android/key.properties + run: | + touch $KEYSTORE_PROPERTIES_PATH + echo 'storeFile=${{ github.workspace }}/decoded_android-keystore.jks' > $KEYSTORE_PROPERTIES_PATH + echo 'keyAlias=${{ secrets.KEYSTORE_KEY_ALIAS }}' >> $KEYSTORE_PROPERTIES_PATH + echo 'storePassword=${{ secrets.KEYSTORE_PASSWORD }}' >> $KEYSTORE_PROPERTIES_PATH + echo 'keyPassword=${{ secrets.KEYSTORE_KEY_PASSWORD }}' >> $KEYSTORE_PROPERTIES_PATH + + + - name: πŸ“¦ Create Android appbundle release + run: | + flutter build appbundle \ + --obfuscate \ + --split-debug-info=${{ github.workspace }}/build/app/outputs/symbols + + - name: πŸš€ Upload Android Release to Play Store + uses: r0adkll/upload-google-play@v1.1.2 + with: + # MUST match the package name defined in `android/app/build.gradle` + # Change all instances of of the package name to this one + packageName: org.dwyl.app + + # Can be 'alpha'/'beta'/'internal'/'production'. + # 'production' is relevant to the final stable version released to ALL clients + # 'internal' can be used for development versions and testing + # 'alpha' and 'beta' can be used for pre-release/staging purposes, with a smaller userbase + track: production + + releaseFiles: ${{ github.workspace }}/build/app/outputs/bundle/release/app-release.aab + serviceAccountJsonPlainText: "${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_KEY_JSON }}" \ No newline at end of file diff --git a/.github/workflows/deploy_ios.yml b/.github/workflows/deploy_ios.yml new file mode 100644 index 00000000..4f1cf81f --- /dev/null +++ b/.github/workflows/deploy_ios.yml @@ -0,0 +1,92 @@ +name: Deploy iOS (Apple App Store) +on: + # Only trigger, when the "build" workflow succeeded (only works in the Master Branch) + workflow_run: + workflows: ["Build & Test"] + types: + - completed + + # Only trigger, when pushing into the `main` branch + push: + branches: [main] + + # DELETE THIS + #pull_request: + # branches: [ "main" ] + +permissions: + contents: write + +jobs: + build-and-deploy_ios: + runs-on: macos-latest + + steps: + + - name: ⬇️ Checkout repository + uses: actions/checkout@v3 + + - name: πŸ” Install Apple certificate and provisioning profile + env: + P12_DISTRIBUTION_CERTIFICATE_BASE64: "${{ secrets.IOS_P12_DISTRIBUTION_CERTIFICATE_BASE64 }}" + P12_DISTRIBUTION_CERTIFICATE_PASSWORD: "${{ secrets.IOS_P12_DISTRIBUTION_CERTIFICATE_PASSWORD }}" + DISTRIBUTION_PROVISIONING_PROFILE_BASE64: "${{ secrets.IOS_DISTRIBUTION_PROVISIONING_PROFILE_BASE64 }}" + KEYCHAIN_PASSWORD: "${{ secrets.IOS_RUNNER_LOCAL_KEYCHAIN_PASSWORD }}" + EXPORT_OPTIONS_BASE64: "${{ secrets.IOS_EXPORT_OPTIONS_BASE64 }}" + run: | + # create variables + CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 + PROVISIONING_PROFILE_PATH=$RUNNER_TEMP/build_pp.mobileprovision + KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db + EXPORT_OPTIONS_PATH="${{ github.workspace }}/app/ios/Runner/ExportOptions.plist" + + # import certificate, provisioning profile and export options from secrets + echo -n "$P12_DISTRIBUTION_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH + echo -n "$DISTRIBUTION_PROVISIONING_PROFILE_BASE64" | base64 --decode -o $PROVISIONING_PROFILE_PATH + echo -n "$EXPORT_OPTIONS_BASE64" | base64 --decode -o $EXPORT_OPTIONS_PATH + + # create temporary keychain + security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + security set-keychain-settings -lut 21600 $KEYCHAIN_PATH + security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + + # import certificate to keychain + security import $CERTIFICATE_PATH -P "$P12_DISTRIBUTION_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH + security list-keychain -d user -s $KEYCHAIN_PATH + + # apply provisioning profile + mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles + cp $PROVISIONING_PROFILE_PATH ~/Library/MobileDevice/Provisioning\ Profiles + + + # Needed to run Flutter-based commands + - name: 🐦 Install Flutter + uses: subosito/flutter-action@v2 + with: + # If the flutter version that is used in development increases, it's recommended this one increases as well + flutter-version: "3.13.5" + channel: "stable" + id: flutter + + # Setting up Melos, which will + #- name: βš™οΈ Setup Melos + # uses: bluefireteam/melos-action@v2 + + - name: πŸ“š Install dependencies + run: flutter pub get + + - name: πŸπŸ“¦ Create iOS appbundle release + run: | + flutter build ipa \ + --release \ + --export-options-plist=ios/Runner/ExportOptions.plist + --obfuscate \ + --split-debug-info=${{ github.workspace }}/build/app/outputs/symbols + + - name: πŸπŸš€ Deploy to App Store (Testflight) + uses: apple-actions/upload-testflight-build@v1 + with: + app-path: ${{ github.workspace }}/app/build/ios/ipa/flutter_ci_cd_demo.ipa + issuer-id: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} + api-key-id: ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }} + api-private-key: ${{ secrets.APP_STORE_CONNECT_API_PRIVATE_KEY }} \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy_web.yml similarity index 64% rename from .github/workflows/deploy.yml rename to .github/workflows/deploy_web.yml index 49b31a3d..116ebac0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy_web.yml @@ -1,28 +1,37 @@ -name: Deploy to Github Pages +name: Deploy Web (GitHub Pages) on: + # Only trigger, when the "build" workflow succeeded (only works in the Master Branch) + workflow_run: + workflows: ["Build & Test"] + types: + - completed + + # Only trigger, when pushing into the `main` branch push: - branches: [ main ] + branches: [main] permissions: contents: write + jobs: - build-and-deploy: + build-and-deploy_web: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - + - name: Install Flutter uses: subosito/flutter-action@v2 with: - channel: 'stable' + flutter-version: "3.13.5" + channel: "stable" - name: Install dependencies run: flutter pub get # See stackoverflow.com/questions/74164386/flutter-web-shows-blank-page-on-github-deployment - - name: Install and Build + - name: Install and Build run: flutter build web --release --web-renderer html - name: Deploy to Github Pages diff --git a/android/app/build.gradle b/android/app/build.gradle index 6cd87e7c..1562754d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -25,6 +25,15 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +// Referencing the keystore +def keystoreProperties = new Properties() +def keystorePropertiesFile = rootProject.file('key.properties') +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) +} + + android { compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion @@ -44,22 +53,27 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.dwyl.app" + applicationId "org.dwyl.app" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. - // Changed because of `gallery_saver` of `flutter_quill`. Though, it will be switched with `gal` in a different PR. Change this back once that occurs - minSdkVersion 21 + minSdkVersion flutter.minSdkVersion targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName } + signingConfigs { + release { + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyPassword'] + storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null + storePassword keystoreProperties['storePassword'] + } + } buildTypes { release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug + signingConfig signingConfigs.release } } } diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index 47897f0c..37753418 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="org.dwyl.app">