From e39126c9c6d9253fc14090b231622079695c798f Mon Sep 17 00:00:00 2001 From: fremartini Date: Thu, 12 Oct 2023 17:29:01 +0200 Subject: [PATCH] update workflow --- .github/actions/build_android/action.yml | 55 +++++ .github/actions/build_ios/action.yml | 119 ++++++++++ .../setup_flutter_environment/action.yml | 18 ++ .github/actions/upload_android/action.yml | 62 +++++ .github/actions/upload_ios/action.yml | 41 ++++ .github/actions/versioning/action.yml | 49 ++++ .github/workflows/build.yml | 218 +++--------------- .../{codesee-arch-diagram.yml => codesee.yml} | 2 +- .github/workflows/release.yml | 133 +++-------- .github/workflows/test.yml | 34 +++ 10 files changed, 444 insertions(+), 287 deletions(-) create mode 100644 .github/actions/build_android/action.yml create mode 100644 .github/actions/build_ios/action.yml create mode 100644 .github/actions/setup_flutter_environment/action.yml create mode 100644 .github/actions/upload_android/action.yml create mode 100644 .github/actions/upload_ios/action.yml create mode 100644 .github/actions/versioning/action.yml rename .github/workflows/{codesee-arch-diagram.yml => codesee.yml} (92%) create mode 100644 .github/workflows/test.yml diff --git a/.github/actions/build_android/action.yml b/.github/actions/build_android/action.yml new file mode 100644 index 000000000..a85a5de54 --- /dev/null +++ b/.github/actions/build_android/action.yml @@ -0,0 +1,55 @@ +name: Build Android app +description: Build and upload Android app +inputs: + version: + required: true + description: "App version" + build_version: + required: true + description: "Build version" + store_artifacts: + required: false + description: "Store artifact" + +runs: + using: "composite" + steps: + - name: Setup Flutter environment + uses: ./.github/actions/setup_flutter_environment + + - name: Replace target URI in Production + if: github.ref_name == 'production' + run: sed -i 's/.env.develop/.env.production/' lib/env/env.dart + shell: bash + + - name: Generate code + run: dart run build_runner build + shell: bash + + - name: Build apk (dev) + if: github.ref_name != 'production' + run: flutter build apk --flavor development --release --build-name ${{ inputs.version }} --build-number ${{ inputs.build_version }} --target lib/main_development.dart + shell: bash + + - name: Build appbundle (prod) + if: ${{ github.ref_name == 'production'}} + run: flutter build appbundle --release --flavor production --build-name ${{ inputs.version }} --build-number ${{ inputs.build_version }} --target lib/main_production.dart + shell: bash + + - name: Upload Android build (dev) + if: ${{ !!inputs.store_artifacts && github.ref_name != 'production'}} + uses: actions/upload-artifact@v3.0.0 + with: + name: android + path: build/app/outputs/flutter-apk + retention-days: 1 + if-no-files-found: error + + - name: Upload Android build (prod) + if: ${{ !!inputs.store_artifacts && github.ref_name == 'production'}} + uses: actions/upload-artifact@v3.0.0 + with: + name: android + path: build/app/outputs/bundle/release + retention-days: 1 + if-no-files-found: error diff --git a/.github/actions/build_ios/action.yml b/.github/actions/build_ios/action.yml new file mode 100644 index 000000000..ff37bc98f --- /dev/null +++ b/.github/actions/build_ios/action.yml @@ -0,0 +1,119 @@ +name: Build iOS app +description: Build and upload iOS app +inputs: + version: + required: true + description: "App version" + build_version: + required: true + description: "Build version" + apple_ios_signing_cert_dev: + required: true + description: "iOS signing certificate" + apple_ios_signing_cert_pw_dev: + required: true + description: "iOS signing certificate password" + apple_ios_provisioning_profile_dev: + required: true + description: "Provisioning profile" + apple_ios_signing_cert_prod: + required: true + description: "TODO" + apple_ios_signing_cert_pw_prod: + required: true + description: "TODO" + apple_ios_provisioning_profile_prod: + required: true + description: "TODO" + apple_keychain_pw: + required: true + description: "Keychain password" + store_artifacts: + required: false + description: "Store artifact" + +runs: + using: "composite" + steps: + - name: Install Apple certificate and provisioning profile (dev) + if: github.ref_name != 'production' + run: .github/scripts/setup-certs.command + env: + APPLE_IOS_SIGNING_CERT: ${{ inputs.apple_ios_signing_cert_dev }} + APPLE_IOS_SIGNING_CERT_PW: ${{ inputs.apple_ios_signing_cert_pw_dev }} + APPLE_IOS_PROVISIONING_PROFILE: ${{ inputs.apple_ios_provisioning_profile_dev }} + APPLE_KEYCHAIN_PW: ${{ inputs.apple_keychain_pw }} + shell: bash + + - name: Install Apple certificate and provisioning profile (prod) + if: github.ref_name == 'production' + run: .github/scripts/setup-certs.command + env: + APPLE_IOS_SIGNING_CERT: ${{ inputs.apple_ios_signing_cert_prod }} + APPLE_IOS_SIGNING_CERT_PW: ${{ inputs.apple_ios_signing_cert_pw_prod }} + APPLE_IOS_PROVISIONING_PROFILE: ${{ inputs.apple_ios_provisioning_profile_prod }} + APPLE_KEYCHAIN_PW: ${{ inputs.apple_keychain_pw }} + shell: bash + + - name: Setup Flutter environment + uses: ./.github/actions/setup_flutter_environment + + - name: Set URI (prod) + if: github.ref_name == 'production' + run: sed -i '' 's/.env.develop/.env.production/' lib/env/env.dart + shell: bash + + - name: Generate code + run: dart run build_runner build + shell: bash + + - name: Build iOS (dev) + if: github.ref_name != 'production' + run: flutter build ios --flavor development --release --no-codesign --build-name ${{ inputs.version }} --build-number ${{ inputs.build_version }} --target lib/main_development.dart + shell: bash + + - name: Build iOS (prod) + if: github.ref_name == 'production' + run: flutter build ios --flavor production --release --no-codesign --build-name ${{ inputs.version }} --build-number ${{ inputs.build_version }} --target lib/main_production.dart + shell: bash + + - name: Build resolve Swift dependencies (dev) + if: github.ref_name != 'production' + run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme development -configuration Release-development + shell: bash + + - name: Build resolve Swift dependencies (prod) + run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme production -configuration Release-production + if: github.ref_name == 'production' + shell: bash + + - name: Build xArchive (dev) + if: github.ref_name != 'production' + run: | + xcodebuild -workspace ios/Runner.xcworkspace -scheme development -configuration Release-development DEVELOPMENT_TEAM=Y5U9T77F2K -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive PROVISIONING_PROFILE_SPECIFIER="development" clean archive CODE_SIGN_IDENTITY="iPhone Developer" + shell: bash + + - name: Build xArchive (prod) + if: github.ref_name == 'production' + run: | + xcodebuild -workspace ios/Runner.xcworkspace -scheme production -configuration Release-production DEVELOPMENT_TEAM=Y5U9T77F2K -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive PROVISIONING_PROFILE_SPECIFIER="githubactions-prod" clean archive CODE_SIGN_IDENTITY="Apple Distribution" + shell: bash + + - name: Export ipa (dev) + if: github.ref_name != 'production' + run: xcodebuild -exportArchive -archivePath build-output/app.xcarchive -exportPath build-output/ios -exportOptionsPlist ios/exportOptions.dev.plist + shell: bash + + - name: Export ipa (prod) + if: github.ref_name == 'production' + run: xcodebuild -exportArchive -archivePath build-output/app.xcarchive -exportPath build-output/ios -exportOptionsPlist ios/exportOptions.prod.plist + shell: bash + + - name: Upload iOS build + if: ${{ inputs.store_artifacts }} + uses: actions/upload-artifact@v3.0.0 + with: + name: ios + path: build-output/ios + retention-days: 1 + if-no-files-found: error \ No newline at end of file diff --git a/.github/actions/setup_flutter_environment/action.yml b/.github/actions/setup_flutter_environment/action.yml new file mode 100644 index 000000000..5170e8083 --- /dev/null +++ b/.github/actions/setup_flutter_environment/action.yml @@ -0,0 +1,18 @@ +name: Setup Flutter environment +description: Setup the Flutter environment + +env: + FLUTTER_VERSION: 3.13.7 + +runs: + using: "composite" + steps: + - name: Setup Flutter environment + uses: subosito/flutter-action@v2.8.0 + with: + flutter-version: ${{ env.FLUTTER_VERSION }} + channel: "stable" + + - name: Download dependencies + run: flutter pub get + shell: bash \ No newline at end of file diff --git a/.github/actions/upload_android/action.yml b/.github/actions/upload_android/action.yml new file mode 100644 index 000000000..27030876a --- /dev/null +++ b/.github/actions/upload_android/action.yml @@ -0,0 +1,62 @@ +name: Upload Android app +description: Upload Android app +inputs: + firebase_android_app_id: + required: true + description: "Firebase Android app id" + firebase_token: + required: true + description: "Firebase token" + android_signing_key: + required: true + description: "Android signing key" + android_key_alias: + required: true + description: "Android key alias" + android_keystore_password: + required: true + description: "Android keystore password" + android_Key_password: + required: true + description: "Android key password" + playstore_service_account: + required: true + description: "Playstore service account json" + +runs: + using: "composite" + steps: + - name: Download artifact + uses: actions/download-artifact@v3.0.0 + with: + name: android + + - name: Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1.3.3 + with: + appId: ${{ inputs.firebase_android_app_id }} + token: ${{ inputs.firebase_token }} + groups: analogio-devs + file: app-development-release.apk + if: github.ref_name != 'production' + + - name: Sign Android appbundle + uses: r0adkll/sign-android-release@v1 + id: sign_app + with: + releaseDirectory: . + signingKeyBase64: ${{ inputs.android_signing_key }} + alias: ${{ inputs.android_key_alias }} + keyStorePassword: ${{ inputs.android_keystore_password }} + keyPassword: ${{ inputs.android_key_password }} + if: github.ref_name == 'production' + + - name: Upload to Google Play Store + uses: r0adkll/upload-google-play@v1.0.16 + with: + serviceAccountJsonPlainText: ${{ inputs.playstore_service_account }} + packageName: dk.analog.digitalclipcard + releaseFiles: ${{ steps.sign_app.outputs.signedReleaseFile }} + track: internal + status: draft + if: github.ref_name == 'production' diff --git a/.github/actions/upload_ios/action.yml b/.github/actions/upload_ios/action.yml new file mode 100644 index 000000000..21d731642 --- /dev/null +++ b/.github/actions/upload_ios/action.yml @@ -0,0 +1,41 @@ +name: Upload iOS app +description: Upload iOS app +inputs: + app_store_connect_username: + required: true + description: "App Store Connect username" + app_store_connect_password: + required: true + description: "App Store Connect password" + firebase_ios_app_id: + required: true + description: "Firebase iOS app id" + firebase_token: + required: true + description: "Firebase token" + +runs: + using: "composite" + steps: + - name: Download artifact + uses: actions/download-artifact@v3.0.0 + with: + name: ios + + - name: Upload to Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1.3.3 + with: + appId: ${{ inputs.firebase_ios_app_id }} + token: ${{ inputs.firebase_token }} + groups: analogio-devs + file: Analog.ipa + if: github.ref_name != 'production' + + - name: Upload to App Store Connect + env: + APP_STORE_CONNECT_USERNAME: ${{ inputs.app_store_connect_username }} + APP_STORE_CONNECT_PASSWORD: ${{ inputs.app_store_connect_password }} + run: | + xcrun altool --upload-app -t ios -f "Analog.ipa" -u "$APP_STORE_CONNECT_USERNAME" -p "$APP_STORE_CONNECT_PASSWORD" + shell: bash + if: github.ref_name == 'production' \ No newline at end of file diff --git a/.github/actions/versioning/action.yml b/.github/actions/versioning/action.yml new file mode 100644 index 000000000..e3d062774 --- /dev/null +++ b/.github/actions/versioning/action.yml @@ -0,0 +1,49 @@ +name: Version +description: Determine version + +outputs: + version: + description: "Version (2.x.x)" + value: ${{ steps.versioning.outputs.version }} + version_tag: + description: "Version tag (v2.x.x)" + value: ${{ steps.versioning.outputs.version_tag }} + build_version: + description: "Build version (7xx)" + value: ${{ steps.build_version.outputs.build_no }} + +runs: + using: "composite" + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Determine versioning + uses: paulhatch/semantic-version@v4.0.3 + id: versioning + with: + tag_prefix: "v" + major_pattern: "(MAJOR)" + minor_pattern: "(MINOR)" + format: "${major}.${minor}.${patch}" + bump_each_commit: false + + - name: Determine build version + id: build_version + run: | + BUILD_NO=$((${{ github.run_number }} + 100)) + echo "::set-output name=build_no::$BUILD_NO" + shell: bash + + - name: Print versioning + run: | + echo "Version: $VERSION" + echo "Version Tag: $VERSION_TAG" + echo "Run No: $BUILD_NO" + env: + VERSION: ${{ steps.versioning.outputs.version }} + VERSION_TAG: ${{ steps.versioning.outputs.version_tag }} + BUILD_NO: ${{ steps.build_version.outputs.build_no }} + shell: bash \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2d9ecdb3c..8fdfc396b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,14 +1,14 @@ -name: Build and test +name: Build application on: - pull_request: + push: branches: [develop, production] workflow_dispatch: workflow_call: inputs: - storeArtifacts: + store_artifacts: type: boolean required: false outputs: @@ -16,137 +16,45 @@ on: description: "Version used for Git tag" value: ${{ jobs.version.outputs.version_tag }} -env: - FLUTTER_VERSION: 3.13.1 - JAVA_VERSION: 11.x - jobs: version: name: Versioning runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Determine versioning - uses: paulhatch/semantic-version@v4.0.3 - id: versioning - with: - tag_prefix: "v" - major_pattern: "(MAJOR)" - minor_pattern: "(MINOR)" - format: "${major}.${minor}.${patch}" - bump_each_commit: false - - - name: Determine build version - id: build_version - run: | - BUILD_NO=$((${{ github.run_number }} + 100)) - echo "::set-output name=build_no::$BUILD_NO" - - - name: Print versioning - run: | - echo "Version: $VERSION" - echo "Version Tag: $VERSION_TAG" - echo "Run No: $BUILD_NO" - env: - VERSION: ${{ steps.versioning.outputs.version }} - VERSION_TAG: ${{ steps.versioning.outputs.version_tag }} - BUILD_NO: ${{ steps.build_version.outputs.build_no }} + - name: Checkout code + uses: actions/checkout@v3 + + - name: Determine version + id: versioning + uses: ./.github/actions/versioning outputs: version: ${{ steps.versioning.outputs.version }} version_tag: ${{ steps.versioning.outputs.version_tag }} - build_version: ${{ steps.build_version.outputs.build_no }} + build_version: ${{ steps.versioning.outputs.build_version }} build_ios: name: Build iOS App runs-on: macos-latest needs: [version] - steps: - name: Checkout code - uses: actions/checkout@v2 - - - name: Install Apple certificate and provisioning profile (dev) - if: github.ref_name != 'production' - run: .github/scripts/setup-certs.command - env: - APPLE_IOS_SIGNING_CERT: ${{ secrets.APPLE_IOS_SIGNING_CERTIFICATE_DEVELOPMENT }} - APPLE_IOS_SIGNING_CERT_PW: ${{ secrets.APPLE_IOS_SIGNING_CERTIFICATE_DEVELOPMENT_PASSWORD }} - APPLE_IOS_PROVISIONING_PROFILE: ${{ secrets.APPLE_IOS_PROVISIONING_PROFILE_DEVELOPMENT }} - APPLE_KEYCHAIN_PW: ${{ secrets.APPLE_KEYCHAIN_PW }} + uses: actions/checkout@v3 - - name: Install Apple certificate and provisioning profile (prod) - if: github.ref_name == 'production' - run: .github/scripts/setup-certs.command - env: - APPLE_IOS_SIGNING_CERT: ${{ secrets.APPLE_IOS_SIGNING_CERT_PROD }} - APPLE_IOS_SIGNING_CERT_PW: ${{ secrets.APPLE_IOS_SIGNING_CERT_PW }} - APPLE_IOS_PROVISIONING_PROFILE: ${{ secrets.APPLE_IOS_PROVISIONING_PROFILE_PROD }} - APPLE_KEYCHAIN_PW: ${{ secrets.APPLE_KEYCHAIN_PW }} - - - name: Setup Java - uses: actions/setup-java@v2.4.0 + - name: Build iOS app + uses: ./.github/actions/build_ios with: - distribution: "adopt" - java-version: ${{ env.JAVA_VERSION }} - - - name: Setup Flutter environment - uses: subosito/flutter-action@v2.3.0 - with: - flutter-version: ${{ env.FLUTTER_VERSION }} - channel: "stable" - - - name: Download dependencies - run: flutter pub get - - - name: Set URI (prod) - if: github.ref_name == 'production' - run: sed -i '' 's/.env.develop/.env.production/' lib/env/env.dart - - - name: Generate code - run: dart run build_runner build - - - name: Build iOS (dev) - if: github.ref_name != 'production' - run: flutter build ios --flavor development --release --no-codesign --build-name ${{ needs.version.outputs.version }} --build-number ${{ needs.version.outputs.build_version }} --target lib/main_development.dart - - name: Build iOS (prod) - if: github.ref_name == 'production' - run: flutter build ios --flavor production --release --no-codesign --build-name ${{ needs.version.outputs.version }} --build-number ${{ needs.version.outputs.build_version }} --target lib/main_production.dart - - name: Build resolve Swift dependencies (dev) - if: github.ref_name != 'production' - run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme development -configuration Release-development - - name: Build resolve Swift dependencies (prod) - run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme production -configuration Release-production - if: github.ref_name == 'production' - - name: Build xArchive (dev) - if: github.ref_name != 'production' - run: | - xcodebuild -workspace ios/Runner.xcworkspace -scheme development -configuration Release-development DEVELOPMENT_TEAM=Y5U9T77F2K -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive PROVISIONING_PROFILE_SPECIFIER="development" clean archive CODE_SIGN_IDENTITY="iPhone Developer" - - name: Build xArchive (prod) - if: github.ref_name == 'production' - run: | - xcodebuild -workspace ios/Runner.xcworkspace -scheme production -configuration Release-production DEVELOPMENT_TEAM=Y5U9T77F2K -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive PROVISIONING_PROFILE_SPECIFIER="githubactions-prod" clean archive CODE_SIGN_IDENTITY="Apple Distribution" - - name: Export ipa (dev) - if: github.ref_name != 'production' - run: xcodebuild -exportArchive -archivePath build-output/app.xcarchive -exportPath build-output/ios -exportOptionsPlist ios/exportOptions.dev.plist - - - name: Export ipa (prod) - if: github.ref_name == 'production' - run: xcodebuild -exportArchive -archivePath build-output/app.xcarchive -exportPath build-output/ios -exportOptionsPlist ios/exportOptions.prod.plist - - - name: Upload iOS build - if: ${{ inputs.storeArtifacts }} - uses: actions/upload-artifact@v3.0.0 - with: - name: ios - path: build-output/ios - retention-days: 1 - if-no-files-found: error + version: ${{ needs.version.outputs.version }} + build_version: ${{ needs.version.outputs.build_version }} + apple_ios_signing_cert_dev: ${{ secrets.APPLE_IOS_SIGNING_CERTIFICATE_DEVELOPMENT }} + apple_ios_signing_cert_pw_dev: ${{ secrets.APPLE_IOS_SIGNING_CERTIFICATE_DEVELOPMENT_PASSWORD }} + apple_ios_provisioning_profile_dev: ${{ secrets.APPLE_IOS_PROVISIONING_PROFILE_DEVELOPMENT }} + apple_ios_signing_cert_prod: ${{ secrets.APPLE_IOS_SIGNING_CERT_PROD }} + apple_ios_signing_cert_pw_prod: ${{ secrets.APPLE_IOS_SIGNING_CERT_PW }} + apple_ios_provisioning_profile_prod: ${{ secrets.APPLE_IOS_PROVISIONING_PROFILE_PROD }} + apple_keychain_pw: ${{ secrets.APPLE_KEYCHAIN_PW }} + store_artifacts: ${{ inputs.store_artifacts }} build_android: name: Build Android App @@ -154,79 +62,11 @@ jobs: needs: [version] steps: - name: Checkout code - uses: actions/checkout@v2 - - - name: Setup Java - uses: actions/setup-java@v2.4.0 - with: - distribution: "adopt" - java-version: ${{ env.JAVA_VERSION }} - - - name: Setup Flutter environment - uses: subosito/flutter-action@v2.3.0 - with: - flutter-version: ${{ env.FLUTTER_VERSION }} - channel: "stable" - - - name: Download dependencies - run: flutter pub get - - - name: Set URI (prod) - if: github.ref_name == 'production' - run: sed -i 's/.env.develop/.env.production/' lib/env/env.dart - - - name: Generate code - run: dart run build_runner build - - - name: Build appbundle (dev) - if: github.ref_name != 'production' - run: flutter build apk --flavor development --release --build-name ${{ needs.version.outputs.version }} --build-number ${{ needs.version.outputs.build_version }} --target lib/main_development.dart - - name: Build appbundle (prod) - if: github.ref_name == 'production' - run: flutter build apk --flavor production --release --dart-define=IS_PROD=true --build-name ${{ needs.version.outputs.version }} --build-number ${{ needs.version.outputs.build_version }} --target lib/main_production.dart - - name: Upload Android build - if: ${{ inputs.storeArtifacts }} - uses: actions/upload-artifact@v3.0.0 - with: - name: android - path: build/app/outputs/flutter-apk - retention-days: 1 - if-no-files-found: error - - test: - name: Test Flutter app - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2.4.0 - - - name: Setup Flutter environment - uses: subosito/flutter-action@v1.5.3 - with: - flutter-version: ${{ env.FLUTTER_VERSION }} - channel: "stable" - - - name: Download dependencies - run: flutter pub get - - - name: Generate code - run: dart run build_runner build - - - name: Check formatting - run: dart format --set-exit-if-changed lib/ - - - name: Static Analysis - run: flutter analyze - - - name: Run Code Metrics - run: dart run dart_code_metrics:metrics --reporter=github lib - - - name: Run tests - run: flutter test --coverage + uses: actions/checkout@v3 - - name: Upload test report to Codecov - uses: codecov/codecov-action@v2.1.0 + - name: Build Android app + uses: ./.github/actions/build_android with: - flags: unittests - file: coverage/lcov.info + version: ${{ needs.version.outputs.version }} + build_version: ${{ needs.version.outputs.build_version }} + store_artifacts: ${{ inputs.store_artifacts }} \ No newline at end of file diff --git a/.github/workflows/codesee-arch-diagram.yml b/.github/workflows/codesee.yml similarity index 92% rename from .github/workflows/codesee-arch-diagram.yml rename to .github/workflows/codesee.yml index 008661e2d..5711c7913 100644 --- a/.github/workflows/codesee-arch-diagram.yml +++ b/.github/workflows/codesee.yml @@ -15,7 +15,7 @@ jobs: codesee: runs-on: ubuntu-latest continue-on-error: true - name: Analyze the repo with CodeSee + name: Analyze repository steps: - uses: Codesee-io/codesee-action@v2 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9255b7d52..c00f31504 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,123 +1,62 @@ name: Release Coffeecard App on: - push: + pull_request: branches: [develop, production] - paths: - - android/** - - assets/** - - ios/** - - lib/** - - openapi/** - - .metadata - - .github/workflows/** - - pubspec.lock - - pubspec.yml - - .env.develop - - .env.production jobs: - build_and_test: + build: uses: ./.github/workflows/build.yml with: - storeArtifacts: true + store_artifacts: true secrets: inherit - dev_upload_ios: - name: Upload iOS build to Firebase App Distribution - runs-on: ubuntu-latest - needs: [build_and_test] - if: github.ref_name == 'develop' - - steps: - - name: Download Artifact - uses: actions/download-artifact@v3.0.0 - with: - name: ios - - name: Firebase App Distribution - uses: wzieba/Firebase-Distribution-Github-Action@v1.3.3 - with: - appId: ${{ secrets.FIREBASE_IOS_APP_ID }} - token: ${{ secrets.FIREBASE_TOKEN }} - groups: analogio-devs - file: Analog.ipa - - dev_upload_android: - name: Upload Android build to Firebase App Distribution - runs-on: ubuntu-latest - needs: [build_and_test] - if: github.ref_name == 'develop' - - steps: - - name: Download artifact - uses: actions/download-artifact@v3.0.0 - with: - name: android - - name: Firebase App Distribution - uses: wzieba/Firebase-Distribution-Github-Action@v1.3.3 - with: - appId: ${{ secrets.FIREBASE_ANDROID_APP_ID }} - token: ${{ secrets.FIREBASE_TOKEN }} - groups: analogio-devs - file: app-development-release.apk - - prod_release_ios: - name: Upload iOS build to App Store connect + upload_ios: + name: Upload iOS build runs-on: macos-latest - needs: [build_and_test] - if: github.ref_name == 'production' - + needs: [build] steps: - - name: Download artifact - uses: actions/download-artifact@v3.0.0 + - name: Checkout code + uses: actions/checkout@v3 + + - name: Upload iOS app + uses: ./.github/actions/upload_ios with: - name: ios - - name: Upload app to App Store Connect - env: - APP_STORE_CONNECT_USERNAME: ${{ secrets.APP_STORE_CONNECT_USERNAME }} - APP_STORE_CONNECT_PASSWORD: ${{ secrets.APP_STORE_CONNECT_PASSWORD }} - run: | - xcrun altool --upload-app -t ios -f "Analog.ipa" -u "$APP_STORE_CONNECT_USERNAME" -p "$APP_STORE_CONNECT_PASSWORD" + app_store_connect_username: ${{ secrets.APP_STORE_CONNECT_USERNAME }} + app_store_connect_password: ${{ secrets.APP_STORE_CONNECT_PASSWORD }} + firebase_ios_app_id: ${{ secrets.FIREBASE_IOS_APP_ID }} + firebase_token: ${{ secrets.FIREBASE_TOKEN }} - prod_release_android: - name: Upload Android build to Play Store + upload_android: + name: Upload Android build runs-on: ubuntu-latest - needs: [build_and_test] - if: github.ref_name == 'production' - + needs: [build] steps: - - name: Download artifact - uses: actions/download-artifact@v3.0.0 - with: - name: android - - name: Sign Android appbundle - uses: r0adkll/sign-android-release@v1 - id: sign_app - with: - releaseDirectory: . - signingKeyBase64: ${{ secrets.ANDROID_KEYSTORE }} - alias: ${{ secrets.ANDROID_KEY_ALIAS }} - keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} - keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }} - - name: Upload to Google Play Store - uses: r0adkll/upload-google-play@v1.0.16 + - name: Checkout code + uses: actions/checkout@v3 + + - name: Upload Android app + uses: ./.github/actions/upload_android with: - serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_SERVICE_ACCOUNT_JSON }} - packageName: dk.analog.digitalclipcard - releaseFiles: ${{ steps.sign_app.outputs.signedReleaseFile }} - track: internal - status: draft + firebase_android_app_id: ${{ secrets.FIREBASE_ANDROID_APP_ID }} + firebase_token: ${{ secrets.FIREBASE_TOKEN }} + android_signing_key: ${{ secrets.ANDROID_KEYSTORE }} + android_key_alias: ${{ secrets.ANDROID_KEY_ALIAS }} + android_keystore_password: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} + android_Key_password: ${{ secrets.ANDROID_KEY_PASSWORD }} + playstore_service_account: ${{ secrets.PLAYSTORE_SERVICE_ACCOUNT_JSON }} tag: name: Git Tag version runs-on: ubuntu-latest - needs: [build_and_test, prod_release_ios, prod_release_android] - if: ${{ needs.prod_release_ios.result == 'success' && needs.prod_release_android.result == 'success' }} + needs: [build, upload_ios, upload_android] + if: ${{ needs.upload_ios.result == 'success' && needs.upload_android.result == 'success' && github.ref_name == 'production' }} steps: - name: Checkout code - uses: actions/checkout@v2 - - name: Git Tag ${{ needs.build_and_test.outputs.version_tag }} + uses: actions/checkout@v3 + + - name: Git Tag ${{ needs.build.outputs.version_tag }} uses: anothrNick/github-tag-action@1.36.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CUSTOM_TAG: ${{ needs.build_and_test.outputs.version_tag }} + CUSTOM_TAG: ${{ needs.build.outputs.version_tag }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..4e352aef3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,34 @@ +name: Test + +on: + pull_request: + branches: [production, develop] + +jobs: + build-and-test: + name: Build and test Flutter app + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2.4.0 + + - name: Setup Flutter environment + uses: ./.github/actions/setup_flutter_environment + + - name: Generate code + run: dart run build_runner build + + - name: Check formatting + run: dart format --set-exit-if-changed lib/ + + - name: Static Analysis + run: flutter analyze + + - name: Run tests + run: flutter test --coverage + + - name: Upload test report to Codecov + uses: codecov/codecov-action@v2.1.0 + with: + flags: unittests + file: coverage/lcov.info \ No newline at end of file