From 1652224fe850fe63fc31e794ab24c1c4b520a3fa Mon Sep 17 00:00:00 2001 From: MarkG Date: Tue, 25 May 2021 15:21:52 +0700 Subject: [PATCH] chore: setup cd pipelines (#32) --- .github/workflows/release_staging.yml | 98 +++++++++ Gemfile | 10 + Gemfile.lock | 207 ++++++++++++++++++ fastlane/Appfile | 6 + fastlane/Fastfile | 48 ++++ fastlane/Pluginfile | 6 + fastlane/README.md | 38 ++++ fastlane/report.xml | 15 ++ ios/Runner.xcodeproj/project.pbxproj | 6 + .../xcshareddata/xcschemes/Runner.xcscheme | 8 +- .../xcshareddata/xcschemes/staging.xcscheme | 43 ++-- ios/Runner/Info.plist | 82 +++---- pubspec.lock | 6 +- 13 files changed, 508 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/release_staging.yml create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 fastlane/Appfile create mode 100644 fastlane/Fastfile create mode 100644 fastlane/Pluginfile create mode 100644 fastlane/README.md create mode 100644 fastlane/report.xml diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml new file mode 100644 index 0000000..132d29c --- /dev/null +++ b/.github/workflows/release_staging.yml @@ -0,0 +1,98 @@ +# This is a lint and test workflow for Flutter CI + +name: Relase (staging) + +# on: +# push: +# branches: +# - develop +# pull_request: +# branches: +# - develop +on: + pull_request: +jobs: + deploy_ios: + name: Build iOS + runs-on: macOS-latest + steps: + # Setup environment + - uses: ruby/setup-ruby@v1.71.0 + with: + ruby-version: '2.7.2' + - uses: actions/checkout@v2.3.2 + + # Setup the Flutter environment. + - uses: subosito/flutter-action@v1 + with: + channel: 'stable' # 'dev', 'alpha', default to: 'stable' + + - name: Get Flutter dependencies. + run: flutter pub get + + - name: Build app + run: flutter build ios --flavor staging -t lib/main-staging.dart --no-codesign + + - name: Install the Apple certificate and provisioning profile + env: + BUILD_CERTIFICATE_BASE64: ${{ secrets.DEVELOPMENT_CERTIFICATE_DATA }} + P12_PASSWORD: ${{ secrets.DEVELOPMENT_CERTIFICATE_PASSPHRASE }} + BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE }} + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + run: | + # create variables + CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 + PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision + KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db + + # import certificate and provisioning profile from secrets + echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH + echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $PP_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_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 $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles + + - name: Export ipa and upload to firebase + uses: maierj/fastlane-action@v2.0.1 + with: + lane: "ios release_staging" + options: '{"token": "${{secrets.FIREBASE_TOKEN}}", "app_id": "${{secrets.FIREBASE_IOS_APP_ID}}"}' + deploy_android: + name: Build android + runs-on: ubuntu-latest + steps: + # Setup Java environment in order to build the Android app. + - uses: ruby/setup-ruby@v1.71.0 + with: + ruby-version: '2.7.2' + - uses: actions/checkout@v2.3.2 + - uses: actions/setup-java@v1 + with: + java-version: '12.x' + + # Setup the Flutter environment. + - uses: subosito/flutter-action@v1 + with: + channel: 'stable' # 'dev', 'alpha', default to: 'stable' + + - name: Get Flutter dependencies. + run: flutter pub get + + - name: Build app + run: flutter build apk --flavor staging -t lib/main-staging.dart --debug + + - name: Upload to firebase + uses: maierj/fastlane-action@v2.0.1 + with: + lane: "android upload_firebase" + options: '{"token": "${{secrets.FIREBASE_TOKEN}}", "app_id": "${{secrets.FIREBASE_ANDROID_APP_ID}}", "apk_path": "build/app/outputs/flutter-apk/app-staging-debug.apk"}' diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..b734015 --- /dev/null +++ b/Gemfile @@ -0,0 +1,10 @@ +# Autogenerated by fastlane +# +# Ensure this file is checked in to source control! + +source "https://rubygems.org" + +gem 'fastlane' + +plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') +eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..86c0f73 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,207 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.3) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + artifactory (3.0.15) + atomos (0.1.3) + aws-eventstream (1.1.1) + aws-partitions (1.462.0) + aws-sdk-core (3.114.0) + aws-eventstream (~> 1, >= 1.0.2) + aws-partitions (~> 1, >= 1.239.0) + aws-sigv4 (~> 1.1) + jmespath (~> 1.0) + aws-sdk-kms (1.43.0) + aws-sdk-core (~> 3, >= 3.112.0) + aws-sigv4 (~> 1.1) + aws-sdk-s3 (1.95.1) + aws-sdk-core (~> 3, >= 3.112.0) + aws-sdk-kms (~> 1) + aws-sigv4 (~> 1.1) + aws-sigv4 (1.2.3) + aws-eventstream (~> 1, >= 1.0.2) + babosa (1.0.4) + claide (1.0.3) + colored (1.2) + colored2 (3.1.2) + commander (4.6.0) + highline (~> 2.0.0) + declarative (0.0.20) + digest-crc (0.6.3) + rake (>= 12.0.0, < 14.0.0) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) + dotenv (2.7.6) + emoji_regex (3.2.2) + excon (0.81.0) + faraday (1.4.2) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.1) + multipart-post (>= 1.2, < 3) + ruby2_keywords (>= 0.0.4) + faraday-cookie_jar (0.0.7) + faraday (>= 0.8.0) + http-cookie (~> 1.0.0) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.1.0) + faraday_middleware (1.0.0) + faraday (~> 1.0) + fastimage (2.2.3) + fastlane (2.184.0) + CFPropertyList (>= 2.3, < 4.0.0) + addressable (>= 2.3, < 3.0.0) + artifactory (~> 3.0) + aws-sdk-s3 (~> 1.0) + babosa (>= 1.0.3, < 2.0.0) + bundler (>= 1.12.0, < 3.0.0) + colored + commander (~> 4.6) + dotenv (>= 2.1.1, < 3.0.0) + emoji_regex (>= 0.1, < 4.0) + excon (>= 0.71.0, < 1.0.0) + faraday (~> 1.0) + faraday-cookie_jar (~> 0.0.6) + faraday_middleware (~> 1.0) + fastimage (>= 2.1.0, < 3.0.0) + gh_inspector (>= 1.1.2, < 2.0.0) + google-apis-androidpublisher_v3 (~> 0.1) + google-apis-playcustomapp_v1 (~> 0.1) + google-cloud-storage (~> 1.31) + highline (~> 2.0) + json (< 3.0.0) + jwt (>= 2.1.0, < 3) + mini_magick (>= 4.9.4, < 5.0.0) + multipart-post (~> 2.0.0) + naturally (~> 2.2) + plist (>= 3.1.0, < 4.0.0) + rubyzip (>= 2.0.0, < 3.0.0) + security (= 0.1.3) + simctl (~> 1.6.3) + terminal-notifier (>= 2.0.0, < 3.0.0) + terminal-table (>= 1.4.5, < 2.0.0) + tty-screen (>= 0.6.3, < 1.0.0) + tty-spinner (>= 0.8.0, < 1.0.0) + word_wrap (~> 1.0.0) + xcodeproj (>= 1.13.0, < 2.0.0) + xcpretty (~> 0.3.0) + xcpretty-travis-formatter (>= 0.0.3) + fastlane-plugin-firebase_app_distribution (0.2.9) + gh_inspector (1.1.3) + google-apis-androidpublisher_v3 (0.4.0) + google-apis-core (~> 0.1) + google-apis-core (0.3.0) + addressable (~> 2.5, >= 2.5.1) + googleauth (~> 0.14) + httpclient (>= 2.8.1, < 3.0) + mini_mime (~> 1.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.0) + rexml + signet (~> 0.14) + webrick + google-apis-iamcredentials_v1 (0.4.0) + google-apis-core (~> 0.1) + google-apis-playcustomapp_v1 (0.3.0) + google-apis-core (~> 0.1) + google-apis-storage_v1 (0.4.0) + google-apis-core (~> 0.1) + google-cloud-core (1.6.0) + google-cloud-env (~> 1.0) + google-cloud-errors (~> 1.0) + google-cloud-env (1.5.0) + faraday (>= 0.17.3, < 2.0) + google-cloud-errors (1.1.0) + google-cloud-storage (1.31.1) + addressable (~> 2.5) + digest-crc (~> 0.4) + google-apis-iamcredentials_v1 (~> 0.1) + google-apis-storage_v1 (~> 0.1) + google-cloud-core (~> 1.2) + googleauth (~> 0.9) + mini_mime (~> 1.0) + googleauth (0.16.2) + faraday (>= 0.17.3, < 2.0) + jwt (>= 1.4, < 3.0) + memoist (~> 0.16) + multi_json (~> 1.11) + os (>= 0.9, < 2.0) + signet (~> 0.14) + highline (2.0.3) + http-cookie (1.0.3) + domain_name (~> 0.5) + httpclient (2.8.3) + jmespath (1.4.0) + json (2.5.1) + jwt (2.2.3) + memoist (0.16.2) + mini_magick (4.11.0) + mini_mime (1.1.0) + multi_json (1.15.0) + multipart-post (2.0.0) + nanaimo (0.3.0) + naturally (2.2.1) + os (1.1.1) + plist (3.6.0) + public_suffix (4.0.6) + rake (13.0.3) + representable (3.1.1) + declarative (< 0.1.0) + trailblazer-option (>= 0.1.1, < 0.2.0) + uber (< 0.2.0) + retriable (3.1.2) + rexml (3.2.5) + rouge (2.0.7) + ruby2_keywords (0.0.4) + rubyzip (2.3.0) + security (0.1.3) + signet (0.15.0) + addressable (~> 2.3) + faraday (>= 0.17.3, < 2.0) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) + simctl (1.6.8) + CFPropertyList + naturally + terminal-notifier (2.0.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + trailblazer-option (0.1.1) + tty-cursor (0.7.1) + tty-screen (0.8.1) + tty-spinner (0.9.3) + tty-cursor (~> 0.7) + uber (0.1.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.7) + unicode-display_width (1.7.0) + webrick (1.7.0) + word_wrap (1.0.0) + xcodeproj (1.19.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.3.0) + xcpretty (0.3.0) + rouge (~> 2.0.7) + xcpretty-travis-formatter (1.0.1) + xcpretty (~> 0.2, >= 0.0.7) + +PLATFORMS + x86_64-darwin-20 + +DEPENDENCIES + fastlane + fastlane-plugin-firebase_app_distribution + +BUNDLED WITH + 2.2.15 diff --git a/fastlane/Appfile b/fastlane/Appfile new file mode 100644 index 0000000..1803063 --- /dev/null +++ b/fastlane/Appfile @@ -0,0 +1,6 @@ +# app_identifier("[[APP_IDENTIFIER]]") # The bundle identifier of your app +# apple_id("[[APPLE_ID]]") # Your Apple email address + + +# For more information about the Appfile, see: +# https://docs.fastlane.tools/advanced/#appfile diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 0000000..8014908 --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,48 @@ +# This file contains the fastlane.tools configuration +# You can find the documentation at https://docs.fastlane.tools +# +# For a list of all available actions, check out +# +# https://docs.fastlane.tools/actions +# +# For a list of all available plugins, check out +# +# https://docs.fastlane.tools/plugins/available-plugins +# + +# Uncomment the line if you want fastlane to automatically update itself +# update_fastlane + +# default_platform(:ios) + +platform :ios do + desc "Export ipa and upload to Firebase" + lane :release_staging do |options| + + build_app( + workspace: "ios/Runner.xcworkspace", + scheme: "staging", + silent: true, + configuration: "Release-staging", + export_options: { + method: "development" + } + ) + + firebase_app_distribution( + app: options[:app_id], + firebase_cli_token: options[:token], + ) + end +end + +platform :android do + lane :upload_firebase do |options| + firebase_app_distribution( + app: options[:app_id], + android_artifact_type: "APK", + android_artifact_path: options[:apk_path], + firebase_cli_token: options[:token], + ) +end +end diff --git a/fastlane/Pluginfile b/fastlane/Pluginfile new file mode 100644 index 0000000..a812a01 --- /dev/null +++ b/fastlane/Pluginfile @@ -0,0 +1,6 @@ +# Autogenerated by fastlane +# +# Ensure this file is checked in to source control! + +gem 'fastlane-plugin-firebase_app_distribution' +gem 'fastlane-plugin-firebase_app_distribution' diff --git a/fastlane/README.md b/fastlane/README.md new file mode 100644 index 0000000..1d028d2 --- /dev/null +++ b/fastlane/README.md @@ -0,0 +1,38 @@ +fastlane documentation +================ +# Installation + +Make sure you have the latest version of the Xcode command line tools installed: + +``` +xcode-select --install +``` + +Install _fastlane_ using +``` +[sudo] gem install fastlane -NV +``` +or alternatively using `brew install fastlane` + +# Available Actions +## iOS +### ios release_staging +``` +fastlane ios release_staging +``` +Export ipa and upload to Firebase + +---- + +## Android +### android release_staging +``` +fastlane android release_staging +``` +Export ipa and upload to Firebase + +---- + +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/fastlane/report.xml b/fastlane/report.xml new file mode 100644 index 0000000..e1978a6 --- /dev/null +++ b/fastlane/report.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 87b09a4..b632a02 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -476,6 +476,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 723E2E286422E7355D82CD8E /* Pods-Runner.debug-production.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = FM5NT9MLCT; PRODUCT_NAME = Runner; }; name = "Debug-production"; @@ -484,6 +485,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = A5EBA3F1CC940667DF79EE46 /* Pods-Runner.profile-production.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = FM5NT9MLCT; PRODUCT_NAME = Runner; }; name = "Profile-production"; @@ -492,6 +494,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = BD4D2DD9EF09CB23F1BFE775 /* Pods-Runner.release-production.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = FM5NT9MLCT; PRODUCT_NAME = Runner; }; name = "Release-production"; @@ -500,6 +503,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 527D168B5B717A9D51E5BDE8 /* Pods-Runner.debug-staging.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = FM5NT9MLCT; PRODUCT_NAME = Runner; }; name = "Debug-staging"; @@ -508,6 +512,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = C2F4412A61D42AC96F3D7D8A /* Pods-Runner.profile-staging.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = FM5NT9MLCT; PRODUCT_NAME = Runner; }; name = "Profile-staging"; @@ -516,6 +521,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = E2E32C4D4960E4DC124372C0 /* Pods-Runner.release-staging.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = FM5NT9MLCT; PRODUCT_NAME = Runner; }; name = "Release-staging"; diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..fb2dffc 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -27,8 +27,6 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> - - - - + + - - + + + + + + - - + shouldUseLaunchSchemeArgsEnv = "YES"> + + - - - + - + - + debugDocumentVersioning = "YES"> + - + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index cda6f0c..cd93082 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -1,45 +1,45 @@ - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(BUNDLE_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleSignature - ???? - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSRequiresIPhoneOS - - UILaunchStoryboardName - $(ASSET_PREFIX)LaunchScreen - UIMainStoryboardFile - Main - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIViewControllerBasedStatusBarAppearance - - + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(BUNDLE_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + $(ASSET_PREFIX)LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + diff --git a/pubspec.lock b/pubspec.lock index 6dec3b4..2ed4b3b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -49,7 +49,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -662,7 +662,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -711,7 +711,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" time: dependency: transitive description: