From 146b208631b7a68f930f2009930c68858199b131 Mon Sep 17 00:00:00 2001 From: Nguyen Thai Date: Mon, 15 May 2023 11:45:33 +0700 Subject: [PATCH] Splited the test report job for forks Refactored fastlane for both ios and android Refactored github workflows (cherry picked from commit c3ff622af05f87e16ae1cadec0c95c87cca3d763) --- .github/workflows/analyze-test.yaml | 26 ++------- .github/workflows/{ci.yaml => build.yaml} | 55 +++++------------- .github/workflows/release.yaml | 51 ++++++----------- .github/workflows/test-reports.yaml | 21 +++++++ android/fastlane/Fastfile | 2 +- android/fastlane/README.md | 40 +++++++++++++ ios/Runner.xcodeproj/project.pbxproj | 22 +++++-- ios/fastlane/Fastfile | 70 ++++------------------- ios/fastlane/Matchfile | 13 +++++ ios/fastlane/README.md | 40 +++++++++++++ prebuild.sh | 6 +- 11 files changed, 187 insertions(+), 159 deletions(-) rename .github/workflows/{ci.yaml => build.yaml} (53%) create mode 100644 .github/workflows/test-reports.yaml create mode 100644 android/fastlane/README.md create mode 100644 ios/fastlane/Matchfile create mode 100644 ios/fastlane/README.md diff --git a/.github/workflows/analyze-test.yaml b/.github/workflows/analyze-test.yaml index 6a35ded16..38512d606 100644 --- a/.github/workflows/analyze-test.yaml +++ b/.github/workflows/analyze-test.yaml @@ -1,5 +1,10 @@ on: - workflow_call: + pull_request: + paths-ignore: + - ".github/**" + - "docs" + - "Jenkinsfile" + - "**/*.md" name: Analyze and test @@ -56,22 +61,3 @@ jobs: with: name: test-reports path: test-report*.json - - report: - runs-on: ubuntu-latest - if: success() || failure() # Always upload report - needs: - - analyze-test - steps: - - uses: actions/checkout@v3 - - - uses: actions/download-artifact@v3 - with: - name: test-reports - - - uses: dorny/test-reporter@v1 - with: - name: Flutter Tests - path: "*.json" - reporter: flutter-json - only-summary: "true" diff --git a/.github/workflows/ci.yaml b/.github/workflows/build.yaml similarity index 53% rename from .github/workflows/ci.yaml rename to .github/workflows/build.yaml index d8647a894..fc76c0015 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/build.yaml @@ -1,23 +1,11 @@ on: workflow_dispatch: - pull_request: - paths-ignore: - - ".github/**" - - "docs" - - "Jenkinsfile" - - "**/*.md" -name: CI +name: Build dev binaries jobs: - analyze-test: - name: Analyze and test - uses: ./.github/workflows/analyze-test.yaml - build-app: name: Build app - needs: - - analyze-test runs-on: ${{ matrix.runner }} strategy: matrix: @@ -41,21 +29,18 @@ jobs: cache-key: deps-${{ hashFiles('**/pubspec.lock') }} # optional, change this to force refresh cache cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path + - name: Setup Fastlane + uses: ruby/setup-ruby@v1 + with: + ruby-version: "ruby" + bundler-cache: true + working-directory: ${{ matrix.os }} + - name: Setup Firebase env env: FIREBASE_ENV: ${{ secrets.FIREBASE_ENV }} run: echo "$FIREBASE_ENV" > ./configurations/env.fcm - - name: Setup Android environment - if: matrix.os == 'android' - env: - PLAY_STORE_UPLOAD_KEY_BASE64: ${{ secrets.PLAY_STORE_UPLOAD_KEY_BASE64 }} - PLAY_STORE_KEY_INFO_BASE64: ${{ secrets.PLAY_STORE_KEY_INFO_BASE64 }} - run: | - echo "$PLAY_STORE_UPLOAD_KEY_BASE64" | base64 --decode > app/keystore.jks - echo "$PLAY_STORE_KEY_INFO_BASE64" | base64 --decode > key.properties - working-directory: ${{ matrix.os }} - - name: Setup Java if: matrix.os == 'android' uses: actions/setup-java@v3 @@ -65,37 +50,25 @@ jobs: - name: Setup iOS environment if: matrix.os == 'ios' - env: - CERTIFICATE_BASE64: ${{ secrets.CERTIFICATE_BASE64 }} - PROVISION_PROFILE_BASE64: ${{ secrets.PROVISION_PROFILE_BASE64 }} - SHAREEXT_PROVISION_PROFILE_BASE64: ${{ secrets.SHAREEXT_PROVISION_PROFILE_BASE64 }} run: | - echo -n "$CERTIFICATE_BASE64" | base64 --decode --output cert.p12 - echo -n "$PROVISION_PROFILE_BASE64" | base64 --decode --output buildpp.mobileprovision - echo -n "$SHAREEXT_PROVISION_PROFILE_BASE64" | base64 --decode --output shareextpp.mobileprovision - flutter pub get && pod install + flutter pub get + pod install && pod update working-directory: ${{ matrix.os }} - - name: Setup Fastlane - uses: ruby/setup-ruby@v1 - with: - ruby-version: "ruby" - bundler-cache: true - working-directory: ${{ matrix.os }} - - name: Run prebuild run: bash prebuild.sh - name: Build env: - CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }} + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} + APPLE_CERTIFICATES_SSH_KEY: ${{ secrets.APPLE_CERTIFICATES_SSH_KEY }} run: bundle exec fastlane dev working-directory: ${{ matrix.os }} - name: Upload artifacts uses: actions/upload-artifact@v3 with: - name: tmail-dev-pr-${{ github.event.pull_request.number }} + name: tmail-dev path: | - build/app/outputs/flutter-apk/app-release.apk + build/app/outputs/flutter-apk/app-debug.apk ios/Runner.ipa diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7084cce91..2773ec3af 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,15 +6,9 @@ on: name: Release jobs: - analyze-test: - name: Analyze and test - uses: ./.github/workflows/analyze-test.yaml - release: name: Release if: startsWith(github.ref, 'refs/tags/v') - needs: - - analyze-test runs-on: ${{ matrix.runner }} strategy: matrix: @@ -45,6 +39,20 @@ jobs: FIREBASE_ENV: ${{ secrets.FIREBASE_ENV }} run: echo "$FIREBASE_ENV" > ./configurations/env.fcm + - name: Setup Fastlane + uses: ruby/setup-ruby@v1 + with: + ruby-version: "ruby" + bundler-cache: true + working-directory: ${{ matrix.os }} + + - name: Setup Java + if: matrix.os == 'android' + uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: "11" + - name: Setup Android environment if: matrix.os == 'android' env: @@ -55,44 +63,23 @@ jobs: echo "$PLAY_STORE_KEY_INFO_BASE64" | base64 --decode > key.properties working-directory: ${{ matrix.os }} - - name: Setup Java - if: matrix.os == 'android' - uses: actions/setup-java@v3 - with: - distribution: "temurin" - java-version: "11" - - name: Setup iOS environment if: matrix.os == 'ios' - env: - CERTIFICATE_BASE64: ${{ secrets.CERTIFICATE_BASE64 }} - PROVISION_PROFILE_BASE64: ${{ secrets.PROVISION_PROFILE_BASE64 }} - SHAREEXT_PROVISION_PROFILE_BASE64: ${{ secrets.SHAREEXT_PROVISION_PROFILE_BASE64 }} - APPLE_API_KEY_BASE64: ${{ secrets.APPLE_API_KEY_BASE64 }} run: | - echo -n "$CERTIFICATE_BASE64" | base64 --decode --output cert.p12 - echo -n "$PROVISION_PROFILE_BASE64" | base64 --decode --output buildpp.mobileprovision - echo -n "$SHAREEXT_PROVISION_PROFILE_BASE64" | base64 --decode --output shareextpp.mobileprovision - echo -n "$APPLE_API_KEY_BASE64" | base64 --decode --output apiKey.p8 - flutter pub get && pod install + flutter pub get + pod install && pod update working-directory: ${{ matrix.os }} - - name: Setup Fastlane - uses: ruby/setup-ruby@v1 - with: - ruby-version: "ruby" - bundler-cache: true - working-directory: ${{ matrix.os }} - - name: Run prebuild run: bash prebuild.sh - name: Build and deploy env: - CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }} - FASTLANE_USER: ${{ secrets.APPLE_ID }} + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} + APPLE_CERTIFICATES_SSH_KEY: ${{ secrets.APPLE_CERTIFICATES_SSH_KEY }} PLAY_STORE_CONFIG_JSON: ${{ secrets.PLAY_STORE_CONFIG_JSON }} APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }} APPLE_KEY_ID: ${{ secrets.APPLE_KEY_ID }} + APPLE_KEY_CONTENT: ${{ secrets.APPLE_KEY_CONTENT }} run: bundle exec fastlane release working-directory: ${{ matrix.os }} diff --git a/.github/workflows/test-reports.yaml b/.github/workflows/test-reports.yaml new file mode 100644 index 000000000..25b52c69d --- /dev/null +++ b/.github/workflows/test-reports.yaml @@ -0,0 +1,21 @@ +on: + workflow_run: + workflows: + - "Analyze and test" + types: + - completed + +name: Test Reports + +jobs: + reports: + name: Upload test reports + runs-on: ubuntu-latest + steps: + - uses: dorny/test-reporter@v1 + with: + artifact: test-reports + name: Flutter Tests + path: "*.json" + reporter: flutter-json + only-summary: "true" diff --git a/android/fastlane/Fastfile b/android/fastlane/Fastfile index 81212ccfd..187896bae 100644 --- a/android/fastlane/Fastfile +++ b/android/fastlane/Fastfile @@ -20,7 +20,7 @@ default_platform(:android) platform :android do desc "Build development version" lane :dev do - sh "flutter build apk --verbose --release --dart-define=SERVER_URL=$SERVER_URL" + sh "flutter build apk --verbose --debug --dart-define=SERVER_URL=$SERVER_URL" end desc "Build and deploy release version" diff --git a/android/fastlane/README.md b/android/fastlane/README.md new file mode 100644 index 000000000..5b34d5751 --- /dev/null +++ b/android/fastlane/README.md @@ -0,0 +1,40 @@ +fastlane documentation +---- + +# Installation + +Make sure you have the latest version of the Xcode command line tools installed: + +```sh +xcode-select --install +``` + +For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane) + +# Available Actions + +## Android + +### android dev + +```sh +[bundle exec] fastlane android dev +``` + +Build development version + +### android release + +```sh +[bundle exec] fastlane android release +``` + +Build and deploy release version + +---- + +This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run. + +More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools). + +The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools). diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 6e0db1039..4808a8c17 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -468,6 +468,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = KUT463DS29; @@ -603,6 +604,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = KUT463DS29; @@ -632,9 +634,12 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + CODE_SIGN_IDENTITY = "Apple Distribution"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Distribution"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = KUT463DS29; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = KUT463DS29; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; @@ -644,7 +649,8 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.linagora.ios.teammail; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = tmail.development.profile; + PROVISIONING_PROFILE_SPECIFIER = tmail.distribution.profile; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = tmail.distribution.profile; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -661,9 +667,11 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = TeamMailShareExtension/TeamMailShareExtension.entitlements; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = KUT463DS29; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = KUT463DS29; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = TeamMailShareExtension/Info.plist; @@ -680,7 +688,8 @@ MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.linagora.ios.teammail.TeamMailShareExtension; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = tmail.ext.ios.development.provisioning.profile; + PROVISIONING_PROFILE_SPECIFIER = tmail.share.ext.development.profile; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = tmail.share.ext.development.profile; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_EMIT_LOC_STRINGS = YES; @@ -700,9 +709,12 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = TeamMailShareExtension/TeamMailShareExtension.entitlements; + CODE_SIGN_IDENTITY = "Apple Distribution"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Distribution"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = KUT463DS29; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = KUT463DS29; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = TeamMailShareExtension/Info.plist; @@ -718,7 +730,8 @@ MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.linagora.ios.teammail.TeamMailShareExtension; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = tmail.ext.ios.development.provisioning.profile; + PROVISIONING_PROFILE_SPECIFIER = tmail.share.ext.distribution.profile; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = tmail.share.ext.distribution.profile; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; @@ -736,6 +749,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = TeamMailShareExtension/TeamMailShareExtension.entitlements; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = KUT463DS29; @@ -754,7 +768,7 @@ MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.linagora.ios.teammail.TeamMailShareExtension; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = tmail.ext.ios.development.provisioning.profile; + PROVISIONING_PROFILE_SPECIFIER = tmail.share.ext.development.profile; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index 77cce508d..c3e65e5fd 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -11,53 +11,24 @@ # # Uncomment the line if you want fastlane to automatically update itself -# update_fastlane +update_fastlane opt_out_usage default_platform(:ios) setup_ci if ENV['CI'] -# Import signing certificate -import_certificate( - certificate_path: "cert.p12", - certificate_password: ENV["CERTIFICATE_PASSWORD"], - keychain_name: ENV["MATCH_KEYCHAIN_NAME"] -) - -# 2 provisioning profiles, 1 for the main app and 1 for the share extension -install_provisioning_profile(path: "buildpp.mobileprovision") -install_provisioning_profile(path: "shareextpp.mobileprovision") - - platform :ios do desc "Build development version" lane :dev do - update_code_signing_settings( - use_automatic_signing: false, - path: "Runner.xcodeproj", - code_sign_identity: "Apple Development" - ) - # Update the provisioning profile for both the main app and extension - update_project_provisioning( - xcodeproj: "Runner.xcodeproj", - profile: "./buildpp.mobileprovision", - target_filter: ".*Runner.*" - ) - update_project_provisioning( - xcodeproj: "Runner.xcodeproj", - profile: "./shareextpp.mobileprovision", - target_filter: ".*TeamMailShareExtension.*" + sync_code_signing( + type: "development", + git_private_key: ENV["APPLE_CERTIFICATES_SSH_KEY"] ) build_app( scheme: "Runner", + configuration: "Debug", workspace: "Runner.xcworkspace", export_method: "development", - export_options: { - provisioningProfiles: { - "com.linagora.ios.teammail": "tmail.development.profile", - "com.linagora.ios.teammail.TeamMailShareExtension": "tmail.share.ext.development.profile" - } - } ) end @@ -67,7 +38,11 @@ platform :ios do app_store_connect_api_key( key_id: ENV["APPLE_KEY_ID"], issuer_id: ENV["APPLE_ISSUER_ID"], - key_filepath: "./apiKey.p8" + key_content: ENV["APPLE_KEY_CONTENT"] + ) + sync_code_signing( + type: "appstore", + git_private_key: ENV["APPLE_CERTIFICATES_SSH_KEY"] ) increment_build_number( build_number: latest_testflight_build_number + 1 @@ -75,32 +50,11 @@ platform :ios do increment_version_number( version_number: last_git_tag.gsub("v", "") ) - update_code_signing_settings( - use_automatic_signing: false, - path: "Runner.xcodeproj", - code_sign_identity: "Apple Distribution" - ) - # Update the provisioning profile for both the main app and extension - update_project_provisioning( - xcodeproj: "Runner.xcodeproj", - profile: "./buildpp.mobileprovision", - target_filter: ".*Runner.*" - ) - update_project_provisioning( - xcodeproj: "Runner.xcodeproj", - profile: "./shareextpp.mobileprovision", - target_filter: ".*TeamMailShareExtension.*" - ) build_app( scheme: "Runner", + configuration: "Release", workspace: "Runner.xcworkspace", - export_method: "app-store", - export_options: { - provisioningProfiles: { - "com.linagora.ios.teammail": "tmail.distribution.profile", - "com.linagora.ios.teammail.TeamMailShareExtension": "tmail.share.ext.distribution.profile" - } - } + export_method: "app-store" ) upload_to_testflight( skip_waiting_for_build_processing: true, diff --git a/ios/fastlane/Matchfile b/ios/fastlane/Matchfile new file mode 100644 index 000000000..4bc5c1ae9 --- /dev/null +++ b/ios/fastlane/Matchfile @@ -0,0 +1,13 @@ +git_url("git@github.com:linagora/apple-certificates.git") + +storage_mode("git") + +type("development") # The default type, can be: appstore, adhoc, enterprise or development + +app_identifier(["com.linagora.ios.teammail", "com.linagora.ios.teammail.TeamMailShareExtension"]) +# username("user@fastlane.tools") # Your Apple Developer Portal username + +# For all available options run `fastlane match --help` +# Remove the # in the beginning of the line to enable the other options + +# The docs are available on https://docs.fastlane.tools/actions/match diff --git a/ios/fastlane/README.md b/ios/fastlane/README.md new file mode 100644 index 000000000..df13b2b76 --- /dev/null +++ b/ios/fastlane/README.md @@ -0,0 +1,40 @@ +fastlane documentation +---- + +# Installation + +Make sure you have the latest version of the Xcode command line tools installed: + +```sh +xcode-select --install +``` + +For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane) + +# Available Actions + +## iOS + +### ios dev + +```sh +[bundle exec] fastlane ios dev +``` + +Build development version + +### ios release + +```sh +[bundle exec] fastlane ios release +``` + +Build and deploy release version + +---- + +This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run. + +More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools). + +The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools). diff --git a/prebuild.sh b/prebuild.sh index a9bb162c3..856b86442 100644 --- a/prebuild.sh +++ b/prebuild.sh @@ -5,11 +5,11 @@ set -e set -x cd core -#flutter pub get +flutter pub get ## Install necessary pods -#cd ../ios -#flutter pub get && pod install +# cd ../ios +# flutter pub get && pod install cd ../model flutter pub get && flutter pub run build_runner build --delete-conflicting-outputs