From ee58f9612612bf623d819426e8333f24ca4aa5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Wed, 26 Apr 2023 13:46:02 +0200 Subject: [PATCH 01/24] feat: init ios plugin (#2) --- .../.circleci/config.yml | 43 ++++ .../.github/workflows/test.yml | 29 +++ plugins/fastlane-plugin-ios_cd/.gitignore | 12 ++ plugins/fastlane-plugin-ios_cd/.rspec | 5 + plugins/fastlane-plugin-ios_cd/.rubocop.yml | 188 ++++++++++++++++++ plugins/fastlane-plugin-ios_cd/.travis.yml | 4 + plugins/fastlane-plugin-ios_cd/Gemfile | 6 + plugins/fastlane-plugin-ios_cd/LICENSE | 21 ++ plugins/fastlane-plugin-ios_cd/README.md | 52 +++++ plugins/fastlane-plugin-ios_cd/Rakefile | 9 + .../fastlane-plugin-ios_cd.gemspec | 36 ++++ .../fastlane-plugin-ios_cd/fastlane/Fastfile | 3 + .../fastlane/Pluginfile | 1 + .../lib/fastlane/plugin/ios_cd.rb | 16 ++ .../plugin/ios_cd/actions/ios_cd_action.rb | 47 +++++ .../plugin/ios_cd/helper/ios_cd_helper.rb | 16 ++ .../lib/fastlane/plugin/ios_cd/version.rb | 5 + .../spec/ios_cd_action_spec.rb | 9 + .../spec/spec_helper.rb | 15 ++ 19 files changed, 517 insertions(+) create mode 100644 plugins/fastlane-plugin-ios_cd/.circleci/config.yml create mode 100644 plugins/fastlane-plugin-ios_cd/.github/workflows/test.yml create mode 100644 plugins/fastlane-plugin-ios_cd/.gitignore create mode 100644 plugins/fastlane-plugin-ios_cd/.rspec create mode 100644 plugins/fastlane-plugin-ios_cd/.rubocop.yml create mode 100644 plugins/fastlane-plugin-ios_cd/.travis.yml create mode 100644 plugins/fastlane-plugin-ios_cd/Gemfile create mode 100644 plugins/fastlane-plugin-ios_cd/LICENSE create mode 100644 plugins/fastlane-plugin-ios_cd/README.md create mode 100644 plugins/fastlane-plugin-ios_cd/Rakefile create mode 100644 plugins/fastlane-plugin-ios_cd/fastlane-plugin-ios_cd.gemspec create mode 100644 plugins/fastlane-plugin-ios_cd/fastlane/Fastfile create mode 100644 plugins/fastlane-plugin-ios_cd/fastlane/Pluginfile create mode 100644 plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd.rb create mode 100644 plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/ios_cd_action.rb create mode 100644 plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb create mode 100644 plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/version.rb create mode 100644 plugins/fastlane-plugin-ios_cd/spec/ios_cd_action_spec.rb create mode 100644 plugins/fastlane-plugin-ios_cd/spec/spec_helper.rb diff --git a/plugins/fastlane-plugin-ios_cd/.circleci/config.yml b/plugins/fastlane-plugin-ios_cd/.circleci/config.yml new file mode 100644 index 0000000..a049044 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/.circleci/config.yml @@ -0,0 +1,43 @@ +# Ruby CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-ruby/ for more details +# +version: 2 +jobs: + build: + docker: + # specify the version you desire here + - image: circleci/ruby:2.5 + + working_directory: ~/repo + + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "Gemfile" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: + name: install dependencies + command: bundle check || bundle install --jobs=4 --retry=3 --path vendor/bundle + + - save_cache: + paths: + - ./vendor + key: v1-dependencies-{{ checksum "Gemfile" }} + + # run tests! + - run: + name: run tests + command: bundle exec rake + + # collect reports + - store_test_results: + path: ~/repo/test-results + - store_artifacts: + path: ~/repo/test-results + destination: test-results diff --git a/plugins/fastlane-plugin-ios_cd/.github/workflows/test.yml b/plugins/fastlane-plugin-ios_cd/.github/workflows/test.yml new file mode 100644 index 0000000..56cf580 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: Test + +on: + push: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile') }} + restore-keys: | + ${{ runner.os }}-gem- + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.5 + - name: Install dependencies + run: bundle check || bundle install --jobs=4 --retry=3 --path vendor/bundle + - name: Run tests + run: bundle exec rake + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: test-results + path: test-results diff --git a/plugins/fastlane-plugin-ios_cd/.gitignore b/plugins/fastlane-plugin-ios_cd/.gitignore new file mode 100644 index 0000000..b7e3986 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/.gitignore @@ -0,0 +1,12 @@ +*.gem +Gemfile.lock + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ +fastlane/README.md +fastlane/report.xml +coverage +test-results diff --git a/plugins/fastlane-plugin-ios_cd/.rspec b/plugins/fastlane-plugin-ios_cd/.rspec new file mode 100644 index 0000000..e1f89b5 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/.rspec @@ -0,0 +1,5 @@ +--require spec_helper +--color +--format d +--format RspecJunitFormatter +--out test-results/rspec/rspec.xml diff --git a/plugins/fastlane-plugin-ios_cd/.rubocop.yml b/plugins/fastlane-plugin-ios_cd/.rubocop.yml new file mode 100644 index 0000000..fc36fbb --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/.rubocop.yml @@ -0,0 +1,188 @@ +--- +require: +- rubocop/require_tools +- rubocop-performance +AllCops: + TargetRubyVersion: 2.6 + NewCops: enable + Include: + - "**/*.rb" + - "**/*file" + - "**/*.gemspec" + - "*/lib/assets/*Template" + - "*/lib/assets/*TemplateAndroid" + Exclude: + - "**/lib/assets/custom_action_template.rb" + - "./vendor/**/*" + - "**/lib/assets/DefaultFastfileTemplate" + - "**/lib/assets/MatchfileTemplate" + - "**/spec/fixtures/broken_files/broken_file.rb" + - "**/*.provisionprofile" +Lint/ErbNewArguments: + Enabled: false +Style/SlicingWithRange: + Enabled: false +Style/MultipleComparison: + Enabled: false +Style/PercentLiteralDelimiters: + Enabled: false +Style/ClassCheck: + EnforcedStyle: kind_of? +Style/FrozenStringLiteralComment: + Enabled: false +Style/SafeNavigation: + Enabled: false +Performance/RegexpMatch: + Enabled: false +Performance/StringReplacement: + Enabled: false +Style/NumericPredicate: + Enabled: false +Metrics/BlockLength: + Enabled: false +Metrics/ModuleLength: + Enabled: false +Naming/VariableNumber: + Enabled: false +Style/MissingRespondToMissing: + Enabled: false +Style/MultilineBlockChain: + Enabled: false +Style/NumericLiteralPrefix: + Enabled: false +Style/TernaryParentheses: + Enabled: false +Style/EmptyMethod: + Enabled: false +Lint/UselessAssignment: + Exclude: + - "**/spec/**/*" +Require/MissingRequireStatement: + Exclude: + - "**/spec/**/*.rb" + - "**/spec_helper.rb" + - spaceship/lib/spaceship/babosa_fix.rb + - fastlane_core/lib/fastlane_core/ui/disable_colors.rb + - "**/Fastfile" + - "**/*.gemspec" + - rakelib/**/* + - "**/*.rake" + - "**/Rakefile" + - fastlane/**/* + - supply/**/* +Layout/FirstHashElementIndentation: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/DotPosition: + Enabled: false +Style/DoubleNegation: + Enabled: false +Style/SymbolArray: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Style/MixinGrouping: + Exclude: + - "**/spec/**/*" +Lint/SuppressedException: + Enabled: false +Lint/UnusedBlockArgument: + Enabled: false +Lint/AmbiguousBlockAssociation: + Enabled: false +Style/GlobalVars: + Enabled: false +Style/ClassAndModuleChildren: + Enabled: false +Style/SpecialGlobalVars: + Enabled: false +Metrics/AbcSize: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Style/WordArray: + MinSize: 19 +Style/SignalException: + Enabled: false +Style/RedundantReturn: + Enabled: false +Style/IfUnlessModifier: + Enabled: false +Style/AndOr: + Enabled: true + EnforcedStyle: conditionals +Metrics/ClassLength: + Max: 320 +Layout/LineLength: + Max: 370 +Metrics/ParameterLists: + Max: 17 +Style/GuardClause: + Enabled: false +Style/StringLiterals: + Enabled: false +Style/ConditionalAssignment: + Enabled: false +Style/RedundantSelf: + Enabled: false +Lint/UnusedMethodArgument: + Enabled: false +Lint/ParenthesesAsGroupedExpression: + Exclude: + - "**/spec/**/*" +Naming/PredicateName: + Enabled: false +Style/PerlBackrefs: + Enabled: false +Layout/SpaceAroundOperators: + Exclude: + - "**/spec/actions_specs/xcodebuild_spec.rb" +Naming/FileName: + Exclude: + - "**/Dangerfile" + - "**/Brewfile" + - "**/Gemfile" + - "**/Podfile" + - "**/Rakefile" + - "**/Fastfile" + - "**/Deliverfile" + - "**/Snapfile" + - "**/Pluginfile" + - "**/*.gemspec" +Style/Documentation: + Enabled: false +Style/MutableConstant: + Enabled: false +Style/ZeroLengthPredicate: + Enabled: false +Style/IfInsideElse: + Enabled: false +Style/CollectionMethods: + Enabled: false +Style/MethodCallWithArgsParentheses: + Enabled: true + IgnoredMethods: + - require + - require_relative + - fastlane_require + - gem + - program + - command + - raise + - attr_accessor + - attr_reader + - desc + - lane + - private_lane + - platform + - to + - not_to + - describe + - it + - be + - context + - before + - after diff --git a/plugins/fastlane-plugin-ios_cd/.travis.yml b/plugins/fastlane-plugin-ios_cd/.travis.yml new file mode 100644 index 0000000..3b35e45 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/.travis.yml @@ -0,0 +1,4 @@ +# os: osx # enable this if you need macOS support +language: ruby +rvm: + - 2.2.4 diff --git a/plugins/fastlane-plugin-ios_cd/Gemfile b/plugins/fastlane-plugin-ios_cd/Gemfile new file mode 100644 index 0000000..7e8dba6 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/Gemfile @@ -0,0 +1,6 @@ +source('https://rubygems.org') + +gemspec + +plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') +eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/plugins/fastlane-plugin-ios_cd/LICENSE b/plugins/fastlane-plugin-ios_cd/LICENSE new file mode 100644 index 0000000..c1a9462 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2023 Malo Léon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/plugins/fastlane-plugin-ios_cd/README.md b/plugins/fastlane-plugin-ios_cd/README.md new file mode 100644 index 0000000..bf19973 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/README.md @@ -0,0 +1,52 @@ +# ios_cd plugin + +[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-ios_cd) + +## Getting Started + +This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-ios_cd`, add it to your project by running: + +```bash +fastlane add_plugin ios_cd +``` + +## About ios_cd + +Testflight and AppStore deployment plugin for Fastlane, simplifying the build and deployment porcess to internal, external, and production channels, and promoting builds for testing. + +**Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here. + +## Example + +Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`. + +**Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary) + +## Run tests for this plugin + +To run both the tests, and code style validation, run + +``` +rake +``` + +To automatically fix many of the styling issues, use +``` +rubocop -a +``` + +## Issues and Feedback + +For any other issues and feedback about this plugin, please submit it to this repository. + +## Troubleshooting + +If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide. + +## Using _fastlane_ Plugins + +For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/). + +## About _fastlane_ + +_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools). diff --git a/plugins/fastlane-plugin-ios_cd/Rakefile b/plugins/fastlane-plugin-ios_cd/Rakefile new file mode 100644 index 0000000..094ebe2 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/Rakefile @@ -0,0 +1,9 @@ +require 'bundler/gem_tasks' + +require 'rspec/core/rake_task' +RSpec::Core::RakeTask.new + +require 'rubocop/rake_task' +RuboCop::RakeTask.new(:rubocop) + +task(default: [:spec, :rubocop]) diff --git a/plugins/fastlane-plugin-ios_cd/fastlane-plugin-ios_cd.gemspec b/plugins/fastlane-plugin-ios_cd/fastlane-plugin-ios_cd.gemspec new file mode 100644 index 0000000..62cdadd --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/fastlane-plugin-ios_cd.gemspec @@ -0,0 +1,36 @@ +lib = File.expand_path("lib", __dir__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'fastlane/plugin/ios_cd/version' + +Gem::Specification.new do |spec| + spec.name = 'fastlane-plugin-ios_cd' + spec.version = Fastlane::IosCd::VERSION + spec.author = 'Malo Léon' + spec.email = 'malo.leon@wyatt-studio.fr' + + spec.summary = 'Testflight and AppStore deployment plugin for Fastlane, simplifying the build and deployment porcess to internal, external, and production channels, and promoting builds for testing.' + # spec.homepage = "https://github.com//fastlane-plugin-ios_cd" + spec.license = "MIT" + + spec.files = Dir["lib/**/*"] + %w(README.md LICENSE) + spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) + spec.require_paths = ['lib'] + + spec.required_ruby_version = '>= 2.6' + + # Don't add a dependency to fastlane or fastlane_re + # since this would cause a circular dependency + + # spec.add_dependency 'your-dependency', '~> 1.0.0' + + spec.add_development_dependency('bundler') + spec.add_development_dependency('fastlane', '>= 2.212.2') + spec.add_development_dependency('pry') + spec.add_development_dependency('rake') + spec.add_development_dependency('rspec') + spec.add_development_dependency('rspec_junit_formatter') + spec.add_development_dependency('rubocop', '1.12.1') + spec.add_development_dependency('rubocop-performance') + spec.add_development_dependency('rubocop-require_tools') + spec.add_development_dependency('simplecov') +end diff --git a/plugins/fastlane-plugin-ios_cd/fastlane/Fastfile b/plugins/fastlane-plugin-ios_cd/fastlane/Fastfile new file mode 100644 index 0000000..e28c871 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/fastlane/Fastfile @@ -0,0 +1,3 @@ +lane :test do + ios_cd +end diff --git a/plugins/fastlane-plugin-ios_cd/fastlane/Pluginfile b/plugins/fastlane-plugin-ios_cd/fastlane/Pluginfile new file mode 100644 index 0000000..e0576b0 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/fastlane/Pluginfile @@ -0,0 +1 @@ +# Autogenerated by fastlane diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd.rb new file mode 100644 index 0000000..f355051 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd.rb @@ -0,0 +1,16 @@ +require 'fastlane/plugin/ios_cd/version' + +module Fastlane + module IosCd + # Return all .rb files inside the "actions" and "helper" directory + def self.all_classes + Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))] + end + end +end + +# By default we want to import all available actions and helpers +# A plugin can contain any number of actions and plugins +Fastlane::IosCd.all_classes.each do |current| + require current +end diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/ios_cd_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/ios_cd_action.rb new file mode 100644 index 0000000..c8ae752 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/ios_cd_action.rb @@ -0,0 +1,47 @@ +require 'fastlane/action' +require_relative '../helper/ios_cd_helper' + +module Fastlane + module Actions + class IosCdAction < Action + def self.run(params) + UI.message("The ios_cd plugin is working!") + end + + def self.description + "Testflight and AppStore deployment plugin for Fastlane, simplifying the build and deployment porcess to internal, external, and production channels, and promoting builds for testing." + end + + def self.authors + ["Malo Léon"] + end + + def self.return_value + # If your method provides a return value, you can describe here what it does + end + + def self.details + # Optional: + "The Fastlane Testflight / Appstore deloyment action streamlines the build and deployment to internal, external and production channels. Allow you to promote builds on testflight beta tests." + end + + def self.available_options + [ + # FastlaneCore::ConfigItem.new(key: :your_option, + # env_name: "IOS_CD_YOUR_OPTION", + # description: "A description of your option", + # optional: false, + # type: String) + ] + end + + def self.is_supported?(platform) + # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example) + # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform + # + # [:ios, :mac, :android].include?(platform) + true + end + end + end +end diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb new file mode 100644 index 0000000..956e06f --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb @@ -0,0 +1,16 @@ +require 'fastlane_core/ui/ui' + +module Fastlane + UI = FastlaneCore::UI unless Fastlane.const_defined?("UI") + + module Helper + class IosCdHelper + # class methods that you define here become available in your action + # as `Helper::IosCdHelper.your_method` + # + def self.show_message + UI.message("Hello from the ios_cd plugin helper!") + end + end + end +end diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/version.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/version.rb new file mode 100644 index 0000000..3415157 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/version.rb @@ -0,0 +1,5 @@ +module Fastlane + module IosCd + VERSION = "0.1.0" + end +end diff --git a/plugins/fastlane-plugin-ios_cd/spec/ios_cd_action_spec.rb b/plugins/fastlane-plugin-ios_cd/spec/ios_cd_action_spec.rb new file mode 100644 index 0000000..46ca2b9 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/spec/ios_cd_action_spec.rb @@ -0,0 +1,9 @@ +describe Fastlane::Actions::IosCdAction do + describe '#run' do + it 'prints a message' do + expect(Fastlane::UI).to receive(:message).with("The ios_cd plugin is working!") + + Fastlane::Actions::IosCdAction.run(nil) + end + end +end diff --git a/plugins/fastlane-plugin-ios_cd/spec/spec_helper.rb b/plugins/fastlane-plugin-ios_cd/spec/spec_helper.rb new file mode 100644 index 0000000..7440b08 --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/spec/spec_helper.rb @@ -0,0 +1,15 @@ +$LOAD_PATH.unshift(File.expand_path('../lib', __dir__)) + +require 'simplecov' + +# SimpleCov.minimum_coverage 95 +SimpleCov.start + +# This module is only used to check the environment is currently a testing env +module SpecHelper +end + +require 'fastlane' # to import the Action super class +require 'fastlane/plugin/ios_cd' # import the actual plugin + +Fastlane.load_actions # load other actions (in case your plugin calls other actions or shared values) -- 2.47.2 From 155d048c18b902b48b12d21be36d091e668554b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Wed, 26 Apr 2023 16:54:43 +0200 Subject: [PATCH 02/24] feat: implement deployement pipeline (#2) --- .../actions/build_and_deploy_action.rb | 2 +- .../.circleci/config.yml | 43 ------- plugins/fastlane-plugin-ios_cd/Gemfile | 2 + .../ios_cd/actions/build_and_deploy_action.rb | 116 ++++++++++++++++++ .../plugin/ios_cd/actions/ios_cd_action.rb | 47 ------- .../plugin/ios_cd/helper/ios_cd_helper.rb | 70 +++++++++-- .../spec/ios_cd_action_spec.rb | 4 +- 7 files changed, 184 insertions(+), 100 deletions(-) delete mode 100644 plugins/fastlane-plugin-ios_cd/.circleci/config.yml create mode 100644 plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb delete mode 100644 plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/ios_cd_action.rb diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy_action.rb index 316ab0e..912ddd9 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy_action.rb @@ -7,7 +7,7 @@ module Fastlane def self.run(params) # Check parameters unless Helper::AndroidCdHelper.is_set(params[:beta_type]) - UI.error("Parameters beta_type cannot be null") + UI.error("❌ Parameters beta_type cannot be null") puts("Error on beta type parameter") end diff --git a/plugins/fastlane-plugin-ios_cd/.circleci/config.yml b/plugins/fastlane-plugin-ios_cd/.circleci/config.yml deleted file mode 100644 index a049044..0000000 --- a/plugins/fastlane-plugin-ios_cd/.circleci/config.yml +++ /dev/null @@ -1,43 +0,0 @@ -# Ruby CircleCI 2.0 configuration file -# -# Check https://circleci.com/docs/2.0/language-ruby/ for more details -# -version: 2 -jobs: - build: - docker: - # specify the version you desire here - - image: circleci/ruby:2.5 - - working_directory: ~/repo - - steps: - - checkout - - # Download and cache dependencies - - restore_cache: - keys: - - v1-dependencies-{{ checksum "Gemfile" }} - # fallback to using the latest cache if no exact match is found - - v1-dependencies- - - - run: - name: install dependencies - command: bundle check || bundle install --jobs=4 --retry=3 --path vendor/bundle - - - save_cache: - paths: - - ./vendor - key: v1-dependencies-{{ checksum "Gemfile" }} - - # run tests! - - run: - name: run tests - command: bundle exec rake - - # collect reports - - store_test_results: - path: ~/repo/test-results - - store_artifacts: - path: ~/repo/test-results - destination: test-results diff --git a/plugins/fastlane-plugin-ios_cd/Gemfile b/plugins/fastlane-plugin-ios_cd/Gemfile index 7e8dba6..c16379a 100644 --- a/plugins/fastlane-plugin-ios_cd/Gemfile +++ b/plugins/fastlane-plugin-ios_cd/Gemfile @@ -2,5 +2,7 @@ source('https://rubygems.org') gemspec +gem 'json' + plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb new file mode 100644 index 0000000..97c408d --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -0,0 +1,116 @@ +require 'fastlane/action' +require_relative '../helper/ios_cd_helper' + +module Fastlane + module Actions + class BuildAndDeploy < Action + def self.run(params) + # Check parameters + unless Helper::IosCdHelper.is_set(params[:beta_type]) + UI.error("❌ Parameters beta_type cannot be null") + puts("Error on beta type parameter") + end + + UI.message("⌛️ Building and deploying to Store in #{params[:beta_type]}..") + + # Decrypt the keys archive and Extract the keys archive + Helper::IosCdHelper.decrypt_ios_keys('.') + + # Retrieve credentials + creds = Helper::IosCdHelper.parseIosCredentials + + UI.message(creds.to_s) + + # Ensure temporary keychain exists + Fastlane::Actions.ensure_temp_keychain(creds['temp_keychain_user'], creds['temp_keychain_password']) + + # Obtain App Store Connect API key + api_key = Fastlane::Actions.app_store_connect_api_key( + key_id: creds['apple_key_id'], + issuer_id: creds['apple_issuer_id'], + key_content: creds['apple_key_content'], + duration: 1200, + in_house: false + ) + + # Increment build number for latest TestFlight build + Fastlane::Actions.increment_build_number({ + build_number: Fastlane::Actions.latest_testflight_build_number + 1, + xcodeproj: "Runner.xcodeproj" + }) + + # Install Cocoapods + Fastlane::Actions.cocoapods( + clean_install: true + ) + + # Set up code signing using match + # Configures and runs `match` which manages code signing certificates and provisioning profiles for the project. + # The function takes the app's bundle identifier, an authorization token for the project's Git repository, and the name and password for a temporary keychain used to store the signing certificate. + # It uses the App Store Connect API key to access the App Store and increment the build number. + # It then runs `gym` to build and sign the app using the selected provisioning profile, and finally, uses `pilot` to upload the app to TestFlight for beta testing. + Fastlane::Actions.match( + type: 'appstore', + app_identifier: creds['app_identifier_extensions'], + git_basic_authorization: Base64.strict_encode64(ENV["GIT_AUTHORIZATION"]), + keychain_name: creds['temp_keychain_user'], + keychain_password: creds['temp_keychain_password'], + api_key: api_key + ) + + # Build and export app using Gym + # Builds and packages an iOS app or framework for distribution to the App Store, TestFlight, or Enterprise distribution. + Fastlane::Actions.gym( + configuration: "Release", + workspace: "Runner.xcworkspace", + scheme: "your_schema", + export_method: "app-store", + export_options: { + provisioningProfiles: creds['provisioning_profiles'] + } + ) + + # Upload build to App Store Connect using Pilot + Fastlane::Actions.pilot( + apple_id: creds['developer_app_id'].to_s, + app_identifier: creds['developer_app_identifier'].to_s, + skip_waiting_for_build_processing: true, + skip_submission: true, + distribute_external: false, + notify_external_testers: false, + ipa: "./Runner.ipa" + ) + + Fastlane::Actions.delete_temp_keychain + end + + def self.description + "Testflight and AppStore deployment plugin for Fastlane, simplifying the build and deployment porcess to internal, external, and production channels, and promoting builds for testing." + end + + def self.authors + ["SAS Wyatt Studio"] + end + + def self.return_value + end + + def self.details + "The Fastlane Testflight / Appstore deloyment action streamlines the build and deployment to internal, external and production channels. Allow you to promote builds on testflight beta tests." + end + + def self.available_options + [ + FastlaneCore::ConfigItem.new(key: :beta_type, + env_name: "IOS_CD_TEST_TYPE", + optional: false, + description: "Type of test (internal, external, production)") + ] + end + + def self.is_supported?(platform) + true + end + end + end +end diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/ios_cd_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/ios_cd_action.rb deleted file mode 100644 index c8ae752..0000000 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/ios_cd_action.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'fastlane/action' -require_relative '../helper/ios_cd_helper' - -module Fastlane - module Actions - class IosCdAction < Action - def self.run(params) - UI.message("The ios_cd plugin is working!") - end - - def self.description - "Testflight and AppStore deployment plugin for Fastlane, simplifying the build and deployment porcess to internal, external, and production channels, and promoting builds for testing." - end - - def self.authors - ["Malo Léon"] - end - - def self.return_value - # If your method provides a return value, you can describe here what it does - end - - def self.details - # Optional: - "The Fastlane Testflight / Appstore deloyment action streamlines the build and deployment to internal, external and production channels. Allow you to promote builds on testflight beta tests." - end - - def self.available_options - [ - # FastlaneCore::ConfigItem.new(key: :your_option, - # env_name: "IOS_CD_YOUR_OPTION", - # description: "A description of your option", - # optional: false, - # type: String) - ] - end - - def self.is_supported?(platform) - # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example) - # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform - # - # [:ios, :mac, :android].include?(platform) - true - end - end - end -end diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb index 956e06f..c5ee24d 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb @@ -1,15 +1,71 @@ +require 'fastlane/action' +require 'json' require 'fastlane_core/ui/ui' module Fastlane - UI = FastlaneCore::UI unless Fastlane.const_defined?("UI") - module Helper class IosCdHelper - # class methods that you define here become available in your action - # as `Helper::IosCdHelper.your_method` - # - def self.show_message - UI.message("Hello from the ios_cd plugin helper!") + # Define method to delete temporary keychain + def delete_temp_keychain(name) + if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db")) + Fastlane::Actions.delete_keychain( + name: name + ) + end + end + + # Define method to create temporary keychain + def create_temp_keychain(name, password) + Fastlane::Actions.create_keychain( + name: name, + password: password, + unlock: false, + timeout: 0 + ) + end + + # Define method to ensure that temporary keychain exists + def ensure_temp_keychain(name, password) + delete_temp_keychain(name) + create_temp_keychain(name, password) + end + + # Check if a parameter is set or not + def self.is_set(variable) + str_variable = variable + str_variable = variable.strip if variable.class.to_s == "String" + variable && !(str_variable.nil? || str_variable.empty?) + end + + # Decrypts ios credentials + def self.decrypt_ios_keys(ios_directory) + # Define the GPG command with options + gpg_command = "gpg --quiet --batch --yes --decrypt --passphrase=#{ENV['IOS_KEYS_SECRET_PASSPHRASE']} \ + --output #{ios_directory}/ios_keys.zip #{ios_directory}/ios_keys.zip.gpg" + + # Execute the GPG command using system + system(gpg_command) + + # Check if the command executed successfully + if $?.success? + + # Move the extracted files to the current directory + `jar xvf #{ios_directory} && mv #{ios_directory}/ios_keys/* #{ios_directory}` + else + puts("Erreur lors de la décompression du fichier GPG") + end + end + + # Parse credential file + def parseIosCredentials(ios_directory) + if File.exists?("#{ios_directory}/ios_crendentials.json") + # Read file and decrypt it + file = File.read("#{ios_directory}/ios_crendentials.json") + JSON.parse(file) + + else + UI.error("❌ Ios credentials doesn't exist") + puts("json file doesn't exist") end end end diff --git a/plugins/fastlane-plugin-ios_cd/spec/ios_cd_action_spec.rb b/plugins/fastlane-plugin-ios_cd/spec/ios_cd_action_spec.rb index 46ca2b9..a5a0dfb 100644 --- a/plugins/fastlane-plugin-ios_cd/spec/ios_cd_action_spec.rb +++ b/plugins/fastlane-plugin-ios_cd/spec/ios_cd_action_spec.rb @@ -1,9 +1,9 @@ -describe Fastlane::Actions::IosCdAction do +describe Fastlane::Actions::BuildAndDeploy do describe '#run' do it 'prints a message' do expect(Fastlane::UI).to receive(:message).with("The ios_cd plugin is working!") - Fastlane::Actions::IosCdAction.run(nil) + Fastlane::Actions::BuildAndDeploy.run(nil) end end end -- 2.47.2 From 0a004a595c3f4c8e9f1e71c9b2452988143e644c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Wed, 26 Apr 2023 17:00:56 +0200 Subject: [PATCH 03/24] refactor: rename action (#2) --- .../fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb | 2 +- plugins/fastlane-plugin-ios_cd/spec/ios_cd_action_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index 97c408d..e62f9b8 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -3,7 +3,7 @@ require_relative '../helper/ios_cd_helper' module Fastlane module Actions - class BuildAndDeploy < Action + class BuildAndDeployAction < Action def self.run(params) # Check parameters unless Helper::IosCdHelper.is_set(params[:beta_type]) diff --git a/plugins/fastlane-plugin-ios_cd/spec/ios_cd_action_spec.rb b/plugins/fastlane-plugin-ios_cd/spec/ios_cd_action_spec.rb index a5a0dfb..1cd4e6f 100644 --- a/plugins/fastlane-plugin-ios_cd/spec/ios_cd_action_spec.rb +++ b/plugins/fastlane-plugin-ios_cd/spec/ios_cd_action_spec.rb @@ -1,9 +1,9 @@ -describe Fastlane::Actions::BuildAndDeploy do +describe Fastlane::Actions::BuildAndDeployAction do describe '#run' do it 'prints a message' do expect(Fastlane::UI).to receive(:message).with("The ios_cd plugin is working!") - Fastlane::Actions::BuildAndDeploy.run(nil) + Fastlane::Actions::BuildAndDeployAction.run(nil) end end end -- 2.47.2 From 87a5b0f8093dedcfea8ccad2ba5d37c4eda1e5e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Wed, 26 Apr 2023 17:04:24 +0200 Subject: [PATCH 04/24] fix: fix unexpected end-of-input error (#2) --- .../lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb index c5ee24d..4ac0a7e 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb @@ -58,14 +58,15 @@ module Fastlane # Parse credential file def parseIosCredentials(ios_directory) - if File.exists?("#{ios_directory}/ios_crendentials.json") + if File.exist?("#{ios_directory}/ios_crendentials.json") # Read file and decrypt it file = File.read("#{ios_directory}/ios_crendentials.json") JSON.parse(file) - else + else UI.error("❌ Ios credentials doesn't exist") puts("json file doesn't exist") + end end end end -- 2.47.2 From 942f3afbf98830d9865cbe97964bb7e97ef58593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Wed, 26 Apr 2023 17:16:03 +0200 Subject: [PATCH 05/24] fix: fix export helper methode (#2) --- .../lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb index 4ac0a7e..8280439 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb @@ -57,7 +57,7 @@ module Fastlane end # Parse credential file - def parseIosCredentials(ios_directory) + def self.parseIosCredentials(ios_directory) if File.exist?("#{ios_directory}/ios_crendentials.json") # Read file and decrypt it file = File.read("#{ios_directory}/ios_crendentials.json") -- 2.47.2 From 89732f1f3f100171dfeba68d3996583fa7199ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Wed, 26 Apr 2023 17:20:22 +0200 Subject: [PATCH 06/24] fix: add ios_directory (#2) --- .../fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index e62f9b8..8f2b6ce 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -17,7 +17,7 @@ module Fastlane Helper::IosCdHelper.decrypt_ios_keys('.') # Retrieve credentials - creds = Helper::IosCdHelper.parseIosCredentials + creds = Helper::IosCdHelper.parseIosCredentials('.') UI.message(creds.to_s) -- 2.47.2 From f66ca731f89d1a6a05aad50e7201d1efe979c865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Thu, 27 Apr 2023 14:23:12 +0200 Subject: [PATCH 07/24] refactor: upadte native fastlane calls (#1 #2) --- plugins/.DS_Store | Bin 0 -> 6148 bytes .../actions/build_and_deploy_action.rb | 18 ++++++++-------- .../android_cd/actions/promote_action.rb | 2 +- .../fastlane-plugin-ios_cd/fastlane/Fastfile | 2 +- .../ios_cd/actions/build_and_deploy_action.rb | 20 +++++++++--------- .../plugin/ios_cd/helper/ios_cd_helper.rb | 16 +++++++------- 6 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 plugins/.DS_Store diff --git a/plugins/.DS_Store b/plugins/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a9ae6c74faa199ad1ceffe5013f3be4d500f8c25 GIT binary patch literal 6148 zcmeHKF-`+P3>-s>NHnPs<$fRqKUhWK1$h7<0uj>bf`Cw8$F~{V3*vN1OM%9cJ-1%Z zu5OC+8Gx-0+iPF}U`}_$r-!NezWc<^TE>WUp3&hRJsz>d%cS~v!nv1tBJU0FBYuYi zc6jD_OU6C-Z}EWb$L6)~_WdsJJbtLMQa}nw0VyB_q`*l9y!X=P7m12eKnh5K9|ipT zQ0R`e;gA@g4u%*3h%=_c_#CqYv3P=58xD!g&@8FMq*@y>Ea}XbR#zJiiAjgG;ltX^ z)+Q8-+j)M8a#&4Nlmb#aAO-%F0ybN3)+@eJ>#dWQ^Ilu% tcl2*#ZIm-aD<(!O=E7U?)vvnZ&)lyKhs2;WA9SLA1Y8%H6!;4Tz5t3?86*Gz literal 0 HcmV?d00001 diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy_action.rb index 912ddd9..92552ef 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy_action.rb @@ -23,17 +23,17 @@ module Fastlane build_number = Fastlane::Actions.number_of_commits # Build the Android App Bundle - Fastlane::Actions.gradle( - task: "bundle", - build_type: "Release", - print_command: true, - properties: { - "android.injected.version.code" => build_number - } - ) + Actions(GradleAction.run( + task: "bundle", + build_type: "Release", + print_command: true, + properties: { + "android.injected.version.code" => build_number + } + )) # Upload the Android App Bundle to the Play Store - Fastlane::Actions.upload_to_play_store( + Actions::UploadToPlayStoreAction.run( track: params[:beta_type], json_key: './service_account_key.json', aab: '../build/app/outputs/bundle/release/app-release.aab', diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/promote_action.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/promote_action.rb index 9bab7e6..e3c9ef4 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/promote_action.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/promote_action.rb @@ -24,7 +24,7 @@ module Fastlane # Upload the Android App Bundle to the Play Store Fastlane::Actions.upload_to_play_store( - track: params[:beta_type], + track: params[:from], json_key: './service_account_key.json', skip_upload_apk: true, skip_upload_aab: true, diff --git a/plugins/fastlane-plugin-ios_cd/fastlane/Fastfile b/plugins/fastlane-plugin-ios_cd/fastlane/Fastfile index e28c871..79918ea 100644 --- a/plugins/fastlane-plugin-ios_cd/fastlane/Fastfile +++ b/plugins/fastlane-plugin-ios_cd/fastlane/Fastfile @@ -1,3 +1,3 @@ lane :test do - ios_cd + build_and_deploy(beta_type: "internal") end diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index 8f2b6ce..8691592 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -22,10 +22,10 @@ module Fastlane UI.message(creds.to_s) # Ensure temporary keychain exists - Fastlane::Actions.ensure_temp_keychain(creds['temp_keychain_user'], creds['temp_keychain_password']) + Helper::IosCdHelper.ensure_temp_keychain(creds['temp_keychain_user'], creds['temp_keychain_password']) # Obtain App Store Connect API key - api_key = Fastlane::Actions.app_store_connect_api_key( + api_key = Actions::AppStoreConnectApiKeyAction.run( key_id: creds['apple_key_id'], issuer_id: creds['apple_issuer_id'], key_content: creds['apple_key_content'], @@ -34,13 +34,13 @@ module Fastlane ) # Increment build number for latest TestFlight build - Fastlane::Actions.increment_build_number({ - build_number: Fastlane::Actions.latest_testflight_build_number + 1, + Actions::IncrementBuildNumberAction.run({ + build_number: Actions::LatestTestflightBuildNumberAction.run({}) + 1, xcodeproj: "Runner.xcodeproj" }) # Install Cocoapods - Fastlane::Actions.cocoapods( + Actions::CocoapodsAction.run( clean_install: true ) @@ -49,7 +49,7 @@ module Fastlane # The function takes the app's bundle identifier, an authorization token for the project's Git repository, and the name and password for a temporary keychain used to store the signing certificate. # It uses the App Store Connect API key to access the App Store and increment the build number. # It then runs `gym` to build and sign the app using the selected provisioning profile, and finally, uses `pilot` to upload the app to TestFlight for beta testing. - Fastlane::Actions.match( + Actions::MatchAction.run( type: 'appstore', app_identifier: creds['app_identifier_extensions'], git_basic_authorization: Base64.strict_encode64(ENV["GIT_AUTHORIZATION"]), @@ -60,7 +60,7 @@ module Fastlane # Build and export app using Gym # Builds and packages an iOS app or framework for distribution to the App Store, TestFlight, or Enterprise distribution. - Fastlane::Actions.gym( + Actions::GymAction.run( configuration: "Release", workspace: "Runner.xcworkspace", scheme: "your_schema", @@ -71,7 +71,7 @@ module Fastlane ) # Upload build to App Store Connect using Pilot - Fastlane::Actions.pilot( + Actions::PilotAction.run( apple_id: creds['developer_app_id'].to_s, app_identifier: creds['developer_app_identifier'].to_s, skip_waiting_for_build_processing: true, @@ -81,7 +81,7 @@ module Fastlane ipa: "./Runner.ipa" ) - Fastlane::Actions.delete_temp_keychain + Actions::DeleteTempKeychainAction.run end def self.description @@ -109,7 +109,7 @@ module Fastlane end def self.is_supported?(platform) - true + [:ios].include?(platform) end end end diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb index 8280439..308892f 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb @@ -6,17 +6,17 @@ module Fastlane module Helper class IosCdHelper # Define method to delete temporary keychain - def delete_temp_keychain(name) + def self.delete_temp_keychain(name) if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db")) - Fastlane::Actions.delete_keychain( + Actions::DeleteKeychainAction.run( name: name ) end end # Define method to create temporary keychain - def create_temp_keychain(name, password) - Fastlane::Actions.create_keychain( + def self.create_temp_keychain(name, password) + Actions::CreateKeychainAction.run( name: name, password: password, unlock: false, @@ -25,7 +25,7 @@ module Fastlane end # Define method to ensure that temporary keychain exists - def ensure_temp_keychain(name, password) + def self.ensure_temp_keychain(name, password) delete_temp_keychain(name) create_temp_keychain(name, password) end @@ -40,7 +40,8 @@ module Fastlane # Decrypts ios credentials def self.decrypt_ios_keys(ios_directory) # Define the GPG command with options - gpg_command = "gpg --quiet --batch --yes --decrypt --passphrase=#{ENV['IOS_KEYS_SECRET_PASSPHRASE']} \ + # gpg_command = "gpg --quiet --batch --yes --decrypt --passphrase=#{ENV['IOS_KEYS_SECRET_PASSPHRASE']} \ + gpg_command = "gpg --quiet --batch --yes --decrypt --passphrase=toto1234 \ --output #{ios_directory}/ios_keys.zip #{ios_directory}/ios_keys.zip.gpg" # Execute the GPG command using system @@ -48,9 +49,8 @@ module Fastlane # Check if the command executed successfully if $?.success? - # Move the extracted files to the current directory - `jar xvf #{ios_directory} && mv #{ios_directory}/ios_keys/* #{ios_directory}` + `jar xvf #{ios_directory}/ios_keys.zip && mv #{ios_directory}/ios_keys/* #{ios_directory}` else puts("Erreur lors de la décompression du fichier GPG") end -- 2.47.2 From 1759498e238a9db3ed70ae32fba8aef3620617b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Thu, 27 Apr 2023 14:49:24 +0200 Subject: [PATCH 08/24] refactor: update params typo (#2) --- .../ios_crendentials.json | 18 ++++++++++++++++ plugins/fastlane-plugin-ios_cd/ios_keys.zip | Bin 0 -> 877 bytes .../fastlane-plugin-ios_cd/ios_keys.zip.gpg | Bin 0 -> 957 bytes .../ios_cd/actions/build_and_deploy_action.rb | 20 +++++++++--------- .../plugin/ios_cd/helper/ios_cd_helper.rb | 8 +++---- 5 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 plugins/fastlane-plugin-ios_cd/ios_crendentials.json create mode 100644 plugins/fastlane-plugin-ios_cd/ios_keys.zip create mode 100644 plugins/fastlane-plugin-ios_cd/ios_keys.zip.gpg diff --git a/plugins/fastlane-plugin-ios_cd/ios_crendentials.json b/plugins/fastlane-plugin-ios_cd/ios_crendentials.json new file mode 100644 index 0000000..44c3dbe --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/ios_crendentials.json @@ -0,0 +1,18 @@ +{ + "developer_app_id":"1624036332", + "developer_app_identifier":"com.jaggerlewis.jl3", + "app_identifier_extensions":[ + "com.jaggerlewis.jl3", + "com.jaggerlewis.jl3.OneSignalNotificationServiceExtension" + + ], + "apple_issuer_id":"69a6de90-9fe1-47e3-e053-5b8c7c11a4d1", + "apple_key_id":"VBRDBQM7SJ", + "apple_key_content":"-----BEGIN PRIVATE KEY-----MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgxLuVvuI7DafrGHTzATTtdB1TgIFkb12qFVyNSj4kuE+gCgYIKoZIzj0DAQehRANCAAQl7PyxfJR2QoKCmpqvjG4mQxMIzehm9TsLAjwLrPya4LWRyxrEEvPG/N5L06udHtv26gLDMR5gY6uOY1pVJX28-----END PRIVATE KEY-----", + "provisioning_profiles":{ + "1624036332": "match AppStore com.jaggerlewis.jl3", + "com.jaggerlewis.jl3.OneSignalNotificationServiceExtension": "match AppStore com.jaggerlewis.jl3.OneSignalNotificationServiceExtension" + }, + "temp_keychain_user":"root", + "temp_keychain_password":"toto1234" +} \ No newline at end of file diff --git a/plugins/fastlane-plugin-ios_cd/ios_keys.zip b/plugins/fastlane-plugin-ios_cd/ios_keys.zip new file mode 100644 index 0000000000000000000000000000000000000000..be63ca3f2f6534f340cc8796ba91403e6466adfa GIT binary patch literal 877 zcmWIWW@Zs#0D*<2v%|m)D8b2~z>t|=9G{(9S*#x#!pp$!pXZeV!XZFhTEWf0$nuqu zfdQ;N0Bj5g0|$yRbC?+z>R&oSz3b8)PoXd^EGS2FDi9 zauBKg9&WH_+p4tHtEchrQb8{&)I&z zvo~FyJw&>MLG*}4^PR7o&bTt#E|zS3>OSW{q0Zm0wE|06-U>d^y>a}c?~_)=Cx%y6 z?C4B-H|wj^>q9dgq7>$ceR&h!{~}OcxTd7Gcz#pwp)1|IcM5;YWk%+n(0^~U^o`Rb(W?v0rtK1yof&m{_rH*EQFory!09EfS$KVL3e zf9Co5*HLj^r;}x`tWuekR&niAZs@AXt=rE}U0N(C+s-2NxaHN|kBy1`<+qP*Q2rNj zD*jOAj^OJ*mREJUabIj{R+TCaGdwMG#lW}$_6rz2?!4Z=_yPg9smbe BL}vg1 literal 0 HcmV?d00001 diff --git a/plugins/fastlane-plugin-ios_cd/ios_keys.zip.gpg b/plugins/fastlane-plugin-ios_cd/ios_keys.zip.gpg new file mode 100644 index 0000000000000000000000000000000000000000..19cdb2c67db8c99ed9fd3b3a162bd97876738c00 GIT binary patch literal 957 zcmV;u148_a4Fm}T0-2V%D#&3@aPrc^>j4IobT;RMlY`19kOy9JV=!Am9UotjZujVP z)*4MU+8yoRv4?=YR|%{t22o^ruDpVPW`tc0rKC`UdCl`RWwod}LuD-+mbxn4SM_iKgTvOm7JBp)NOQ`N zSJIhO%N=Jlq9u5EEki6Z8Qt4wX&85D(4zQ&X+PrAqD^o{H6@PR`#gJ8I9#GJ!G`aU zsc2xbz$xYJLG;o*k8tmrvx*d|M>)Kkp~<*-R_rf7m$Uo)=b4|X8Iny&WE=`94c^NY z6g35ILt72tu}y8I^rtig-i7uRy+veIm^@W$g7<&mGYi_J*RQlv=rmPy&w(^8?4Jq% zeh@m~9?!1s8-?gv23ov5*3@aq9tCE%Xr>2wOXa>BHuO>NWdE)%Z zz?)HX7RCkT?cbmB8ofF*C`ZSIsK}dez^AaE&88Txx^KWzB|WnBtxK;fzi@@Fe%9pZ z$5;^L(Rf=@J1m&>#Ag(9F#LG4r>GBCc9VTK%9^7BI~o9kuf$4VL3RlSKP@y9nVXp# z#J^U_MW1=^?x<3o{|wjHaU1yu??3j~11>^Q36QD|aOq;g9rM5&uy)OQSP-Is>Mzyx z5i2pO-a_Mxd~b2i#x`RHW($s7gDCX>gLntvQRy`7%M(5nythB+BmNRXStx{Dhp>e1 z(5Z_VV@?ol-QbjU(}Y#$q*)MS${sN$?`R^Qp^t=kd=({2`EB2lNak46Z@{qT{s!#s z{Cbu;y&hVT{}xI{V=tM%Qy44aFW9OozMvcPwgXkCUJK_OJRu}EUdGhYLM1yY=WjhYVC78{U}Ouv>P}`KB^GC+B=>BEjx}=n;;a(^DE~ zzDn8A{%@8^dlQ4L>wPYEN}P)cPNSX3cWY?g){hT!%2t#;X2sF_>vS%O=LzpQ)Z-yN zB0AM!gc@K2vi2uULusKTUGjVy$Di>$KgE&s&GW3s3}~OHkb> literal 0 HcmV?d00001 diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index 8691592..588919e 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -25,13 +25,13 @@ module Fastlane Helper::IosCdHelper.ensure_temp_keychain(creds['temp_keychain_user'], creds['temp_keychain_password']) # Obtain App Store Connect API key - api_key = Actions::AppStoreConnectApiKeyAction.run( + api_key = Actions::AppStoreConnectApiKeyAction.run({ key_id: creds['apple_key_id'], issuer_id: creds['apple_issuer_id'], key_content: creds['apple_key_content'], duration: 1200, in_house: false - ) + }) # Increment build number for latest TestFlight build Actions::IncrementBuildNumberAction.run({ @@ -40,27 +40,27 @@ module Fastlane }) # Install Cocoapods - Actions::CocoapodsAction.run( + Actions::CocoapodsAction.run({ clean_install: true - ) + }) # Set up code signing using match # Configures and runs `match` which manages code signing certificates and provisioning profiles for the project. # The function takes the app's bundle identifier, an authorization token for the project's Git repository, and the name and password for a temporary keychain used to store the signing certificate. # It uses the App Store Connect API key to access the App Store and increment the build number. # It then runs `gym` to build and sign the app using the selected provisioning profile, and finally, uses `pilot` to upload the app to TestFlight for beta testing. - Actions::MatchAction.run( + Actions::MatchAction.run({ type: 'appstore', app_identifier: creds['app_identifier_extensions'], git_basic_authorization: Base64.strict_encode64(ENV["GIT_AUTHORIZATION"]), keychain_name: creds['temp_keychain_user'], keychain_password: creds['temp_keychain_password'], api_key: api_key - ) + }) # Build and export app using Gym # Builds and packages an iOS app or framework for distribution to the App Store, TestFlight, or Enterprise distribution. - Actions::GymAction.run( + Actions::GymAction.run({ configuration: "Release", workspace: "Runner.xcworkspace", scheme: "your_schema", @@ -68,10 +68,10 @@ module Fastlane export_options: { provisioningProfiles: creds['provisioning_profiles'] } - ) + }) # Upload build to App Store Connect using Pilot - Actions::PilotAction.run( + Actions::PilotAction.run({ apple_id: creds['developer_app_id'].to_s, app_identifier: creds['developer_app_identifier'].to_s, skip_waiting_for_build_processing: true, @@ -79,7 +79,7 @@ module Fastlane distribute_external: false, notify_external_testers: false, ipa: "./Runner.ipa" - ) + }) Actions::DeleteTempKeychainAction.run end diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb index 308892f..aa7860e 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb @@ -8,20 +8,20 @@ module Fastlane # Define method to delete temporary keychain def self.delete_temp_keychain(name) if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db")) - Actions::DeleteKeychainAction.run( + Actions::DeleteKeychainAction.run({ name: name - ) + }) end end # Define method to create temporary keychain def self.create_temp_keychain(name, password) - Actions::CreateKeychainAction.run( + Actions::CreateKeychainAction.run({ name: name, password: password, unlock: false, timeout: 0 - ) + }) end # Define method to ensure that temporary keychain exists -- 2.47.2 From cc2cd8ea68f56b60a85e6c6923050bcddc80eb09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Thu, 27 Apr 2023 16:52:22 +0200 Subject: [PATCH 09/24] fix: update syntax (#2) --- .../ios_crendentials.json | 2 +- .../ios_cd/actions/build_and_deploy_action.rb | 38 ++++++++++--------- .../plugin/ios_cd/helper/ios_cd_helper.rb | 8 ++-- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/plugins/fastlane-plugin-ios_cd/ios_crendentials.json b/plugins/fastlane-plugin-ios_cd/ios_crendentials.json index 44c3dbe..909147c 100644 --- a/plugins/fastlane-plugin-ios_cd/ios_crendentials.json +++ b/plugins/fastlane-plugin-ios_cd/ios_crendentials.json @@ -8,7 +8,7 @@ ], "apple_issuer_id":"69a6de90-9fe1-47e3-e053-5b8c7c11a4d1", "apple_key_id":"VBRDBQM7SJ", - "apple_key_content":"-----BEGIN PRIVATE KEY-----MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgxLuVvuI7DafrGHTzATTtdB1TgIFkb12qFVyNSj4kuE+gCgYIKoZIzj0DAQehRANCAAQl7PyxfJR2QoKCmpqvjG4mQxMIzehm9TsLAjwLrPya4LWRyxrEEvPG/N5L06udHtv26gLDMR5gY6uOY1pVJX28-----END PRIVATE KEY-----", + "apple_key_content":"-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgxLuVvuI7DafrGHTz\nATTtdB1TgIFkb12qFVyNSj4kuE+gCgYIKoZIzj0DAQehRANCAAQl7PyxfJR2QoKC\nmpqvjG4mQxMIzehm9TsLAjwLrPya4LWRyxrEEvPG/N5L06udHtv26gLDMR5gY6uO\nY1pVJX28\n-----END PRIVATE KEY-----", "provisioning_profiles":{ "1624036332": "match AppStore com.jaggerlewis.jl3", "com.jaggerlewis.jl3.OneSignalNotificationServiceExtension": "match AppStore com.jaggerlewis.jl3.OneSignalNotificationServiceExtension" diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index 588919e..e8c3f8f 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -19,48 +19,50 @@ module Fastlane # Retrieve credentials creds = Helper::IosCdHelper.parseIosCredentials('.') - UI.message(creds.to_s) - # Ensure temporary keychain exists Helper::IosCdHelper.ensure_temp_keychain(creds['temp_keychain_user'], creds['temp_keychain_password']) # Obtain App Store Connect API key - api_key = Actions::AppStoreConnectApiKeyAction.run({ - key_id: creds['apple_key_id'], - issuer_id: creds['apple_issuer_id'], - key_content: creds['apple_key_content'], + api_key = Actions::AppStoreConnectApiKeyAction.run( + key_id: creds['apple_key_id'].to_s, + issuer_id: creds['apple_issuer_id'].to_s, + key_content: creds['apple_key_content'].to_s, duration: 1200, in_house: false - }) + ) # Increment build number for latest TestFlight build - Actions::IncrementBuildNumberAction.run({ - build_number: Actions::LatestTestflightBuildNumberAction.run({}) + 1, + Actions::IncrementBuildNumberAction.run( + build_number: Actions::LatestTestflightBuildNumberAction.run( + api_key: api_key, + team_id: "118579280", + team_name: "Jagger & Lewis" + ) + 1, xcodeproj: "Runner.xcodeproj" - }) + ) # Install Cocoapods - Actions::CocoapodsAction.run({ + Actions::CocoapodsAction.run( clean_install: true - }) + ) # Set up code signing using match # Configures and runs `match` which manages code signing certificates and provisioning profiles for the project. # The function takes the app's bundle identifier, an authorization token for the project's Git repository, and the name and password for a temporary keychain used to store the signing certificate. # It uses the App Store Connect API key to access the App Store and increment the build number. # It then runs `gym` to build and sign the app using the selected provisioning profile, and finally, uses `pilot` to upload the app to TestFlight for beta testing. - Actions::MatchAction.run({ + Actions::MatchAction.run( type: 'appstore', app_identifier: creds['app_identifier_extensions'], git_basic_authorization: Base64.strict_encode64(ENV["GIT_AUTHORIZATION"]), keychain_name: creds['temp_keychain_user'], keychain_password: creds['temp_keychain_password'], api_key: api_key - }) + ) # Build and export app using Gym # Builds and packages an iOS app or framework for distribution to the App Store, TestFlight, or Enterprise distribution. - Actions::GymAction.run({ + Actions::GymAction.run( configuration: "Release", workspace: "Runner.xcworkspace", scheme: "your_schema", @@ -68,10 +70,10 @@ module Fastlane export_options: { provisioningProfiles: creds['provisioning_profiles'] } - }) + ) # Upload build to App Store Connect using Pilot - Actions::PilotAction.run({ + Actions::PilotAction.run( apple_id: creds['developer_app_id'].to_s, app_identifier: creds['developer_app_identifier'].to_s, skip_waiting_for_build_processing: true, @@ -79,7 +81,7 @@ module Fastlane distribute_external: false, notify_external_testers: false, ipa: "./Runner.ipa" - }) + ) Actions::DeleteTempKeychainAction.run end diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb index aa7860e..308892f 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb @@ -8,20 +8,20 @@ module Fastlane # Define method to delete temporary keychain def self.delete_temp_keychain(name) if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db")) - Actions::DeleteKeychainAction.run({ + Actions::DeleteKeychainAction.run( name: name - }) + ) end end # Define method to create temporary keychain def self.create_temp_keychain(name, password) - Actions::CreateKeychainAction.run({ + Actions::CreateKeychainAction.run( name: name, password: password, unlock: false, timeout: 0 - }) + ) end # Define method to ensure that temporary keychain exists -- 2.47.2 From ec414c9864a937da9e3e28ccf705f60367942ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Thu, 27 Apr 2023 18:05:53 +0200 Subject: [PATCH 10/24] fix: add necessary args (#2) --- plugins/fastlane-plugin-ios_cd/Gemfile | 1 + .../ios_cd/actions/build_and_deploy_action.rb | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/plugins/fastlane-plugin-ios_cd/Gemfile b/plugins/fastlane-plugin-ios_cd/Gemfile index c16379a..0a7944e 100644 --- a/plugins/fastlane-plugin-ios_cd/Gemfile +++ b/plugins/fastlane-plugin-ios_cd/Gemfile @@ -3,6 +3,7 @@ source('https://rubygems.org') gemspec gem 'json' +gem "cocoapods" plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index e8c3f8f..736bc47 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -31,13 +31,19 @@ module Fastlane in_house: false ) - # Increment build number for latest TestFlight build - Actions::IncrementBuildNumberAction.run( - build_number: Actions::LatestTestflightBuildNumberAction.run( + last_testflight_build_number = + Actions::LatestTestflightBuildNumberAction.run( api_key: api_key, team_id: "118579280", - team_name: "Jagger & Lewis" - ) + 1, + team_name: "Jagger & Lewis", + platform: 'ios', + app_identifier: creds['developer_app_identifier'].to_s, + username: "leonmalo@sfr.fr" + ) + 1 + + # Increment build number for latest TestFlight build + Actions::IncrementBuildNumberAction.run( + build_number: last_testflight_build_number + 1, xcodeproj: "Runner.xcodeproj" ) -- 2.47.2 From d88276a0ece7981c7c0d1d634db1b3d6c6ea9036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Thu, 27 Apr 2023 18:17:58 +0200 Subject: [PATCH 11/24] fix: add clean args to cocoapods action args (#2) --- .../fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index 736bc47..6f169f8 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -49,7 +49,8 @@ module Fastlane # Install Cocoapods Actions::CocoapodsAction.run( - clean_install: true + clean_install: true, + clean: true ) # Set up code signing using match -- 2.47.2 From 74d3527b40be0b54b04363fb6ec8a51c53e754a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Thu, 27 Apr 2023 18:20:00 +0200 Subject: [PATCH 12/24] fix: add integrate args to cocoapods action args (#2) --- .../fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index 6f169f8..a2a1fdd 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -50,7 +50,8 @@ module Fastlane # Install Cocoapods Actions::CocoapodsAction.run( clean_install: true, - clean: true + clean: true, + integrate: true ) # Set up code signing using match -- 2.47.2 From 502c7b06e45e8bc6f6c1150c9ab2bac743b07eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Thu, 27 Apr 2023 18:24:03 +0200 Subject: [PATCH 13/24] fix: add integrate args to cocoapods action args (#2) --- .../fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index a2a1fdd..85ab9a6 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -51,7 +51,8 @@ module Fastlane Actions::CocoapodsAction.run( clean_install: true, clean: true, - integrate: true + integrate: true, + podfile: "./Podfile" ) # Set up code signing using match -- 2.47.2 From 24a09b44c4ea93a0310458fe89aef42d42e0e451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 1 May 2023 21:16:35 +0200 Subject: [PATCH 14/24] feat: add logs and parameters to match --- .../ios_crendentials.json | 18 ------------------ plugins/fastlane-plugin-ios_cd/ios_keys.zip | Bin 877 -> 0 bytes .../fastlane-plugin-ios_cd/ios_keys.zip.gpg | Bin 957 -> 0 bytes .../ios_cd/actions/build_and_deploy_action.rb | 17 ++++++++++++++++- 4 files changed, 16 insertions(+), 19 deletions(-) delete mode 100644 plugins/fastlane-plugin-ios_cd/ios_crendentials.json delete mode 100644 plugins/fastlane-plugin-ios_cd/ios_keys.zip delete mode 100644 plugins/fastlane-plugin-ios_cd/ios_keys.zip.gpg diff --git a/plugins/fastlane-plugin-ios_cd/ios_crendentials.json b/plugins/fastlane-plugin-ios_cd/ios_crendentials.json deleted file mode 100644 index 909147c..0000000 --- a/plugins/fastlane-plugin-ios_cd/ios_crendentials.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "developer_app_id":"1624036332", - "developer_app_identifier":"com.jaggerlewis.jl3", - "app_identifier_extensions":[ - "com.jaggerlewis.jl3", - "com.jaggerlewis.jl3.OneSignalNotificationServiceExtension" - - ], - "apple_issuer_id":"69a6de90-9fe1-47e3-e053-5b8c7c11a4d1", - "apple_key_id":"VBRDBQM7SJ", - "apple_key_content":"-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgxLuVvuI7DafrGHTz\nATTtdB1TgIFkb12qFVyNSj4kuE+gCgYIKoZIzj0DAQehRANCAAQl7PyxfJR2QoKC\nmpqvjG4mQxMIzehm9TsLAjwLrPya4LWRyxrEEvPG/N5L06udHtv26gLDMR5gY6uO\nY1pVJX28\n-----END PRIVATE KEY-----", - "provisioning_profiles":{ - "1624036332": "match AppStore com.jaggerlewis.jl3", - "com.jaggerlewis.jl3.OneSignalNotificationServiceExtension": "match AppStore com.jaggerlewis.jl3.OneSignalNotificationServiceExtension" - }, - "temp_keychain_user":"root", - "temp_keychain_password":"toto1234" -} \ No newline at end of file diff --git a/plugins/fastlane-plugin-ios_cd/ios_keys.zip b/plugins/fastlane-plugin-ios_cd/ios_keys.zip deleted file mode 100644 index be63ca3f2f6534f340cc8796ba91403e6466adfa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 877 zcmWIWW@Zs#0D*<2v%|m)D8b2~z>t|=9G{(9S*#x#!pp$!pXZeV!XZFhTEWf0$nuqu zfdQ;N0Bj5g0|$yRbC?+z>R&oSz3b8)PoXd^EGS2FDi9 zauBKg9&WH_+p4tHtEchrQb8{&)I&z zvo~FyJw&>MLG*}4^PR7o&bTt#E|zS3>OSW{q0Zm0wE|06-U>d^y>a}c?~_)=Cx%y6 z?C4B-H|wj^>q9dgq7>$ceR&h!{~}OcxTd7Gcz#pwp)1|IcM5;YWk%+n(0^~U^o`Rb(W?v0rtK1yof&m{_rH*EQFory!09EfS$KVL3e zf9Co5*HLj^r;}x`tWuekR&niAZs@AXt=rE}U0N(C+s-2NxaHN|kBy1`<+qP*Q2rNj zD*jOAj^OJ*mREJUabIj{R+TCaGdwMG#lW}$_6rz2?!4Z=_yPg9smbe BL}vg1 diff --git a/plugins/fastlane-plugin-ios_cd/ios_keys.zip.gpg b/plugins/fastlane-plugin-ios_cd/ios_keys.zip.gpg deleted file mode 100644 index 19cdb2c67db8c99ed9fd3b3a162bd97876738c00..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 957 zcmV;u148_a4Fm}T0-2V%D#&3@aPrc^>j4IobT;RMlY`19kOy9JV=!Am9UotjZujVP z)*4MU+8yoRv4?=YR|%{t22o^ruDpVPW`tc0rKC`UdCl`RWwod}LuD-+mbxn4SM_iKgTvOm7JBp)NOQ`N zSJIhO%N=Jlq9u5EEki6Z8Qt4wX&85D(4zQ&X+PrAqD^o{H6@PR`#gJ8I9#GJ!G`aU zsc2xbz$xYJLG;o*k8tmrvx*d|M>)Kkp~<*-R_rf7m$Uo)=b4|X8Iny&WE=`94c^NY z6g35ILt72tu}y8I^rtig-i7uRy+veIm^@W$g7<&mGYi_J*RQlv=rmPy&w(^8?4Jq% zeh@m~9?!1s8-?gv23ov5*3@aq9tCE%Xr>2wOXa>BHuO>NWdE)%Z zz?)HX7RCkT?cbmB8ofF*C`ZSIsK}dez^AaE&88Txx^KWzB|WnBtxK;fzi@@Fe%9pZ z$5;^L(Rf=@J1m&>#Ag(9F#LG4r>GBCc9VTK%9^7BI~o9kuf$4VL3RlSKP@y9nVXp# z#J^U_MW1=^?x<3o{|wjHaU1yu??3j~11>^Q36QD|aOq;g9rM5&uy)OQSP-Is>Mzyx z5i2pO-a_Mxd~b2i#x`RHW($s7gDCX>gLntvQRy`7%M(5nythB+BmNRXStx{Dhp>e1 z(5Z_VV@?ol-QbjU(}Y#$q*)MS${sN$?`R^Qp^t=kd=({2`EB2lNak46Z@{qT{s!#s z{Cbu;y&hVT{}xI{V=tM%Qy44aFW9OozMvcPwgXkCUJK_OJRu}EUdGhYLM1yY=WjhYVC78{U}Ouv>P}`KB^GC+B=>BEjx}=n;;a(^DE~ zzDn8A{%@8^dlQ4L>wPYEN}P)cPNSX3cWY?g){hT!%2t#;X2sF_>vS%O=LzpQ)Z-yN zB0AM!gc@K2vi2uULusKTUGjVy$Di>$KgE&s&GW3s3}~OHkb> diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index 85ab9a6..4a3d2cd 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -15,12 +15,15 @@ module Fastlane # Decrypt the keys archive and Extract the keys archive Helper::IosCdHelper.decrypt_ios_keys('.') + UI.message("👉🏼 Credentials decrypted.") # Retrieve credentials creds = Helper::IosCdHelper.parseIosCredentials('.') + UI.message("👉🏼 Credentials parsed.") # Ensure temporary keychain exists Helper::IosCdHelper.ensure_temp_keychain(creds['temp_keychain_user'], creds['temp_keychain_password']) + UI.message("👉🏼 New keychain created") # Obtain App Store Connect API key api_key = Actions::AppStoreConnectApiKeyAction.run( @@ -30,6 +33,7 @@ module Fastlane duration: 1200, in_house: false ) + UI.message("👉🏼 API Key formated") last_testflight_build_number = Actions::LatestTestflightBuildNumberAction.run( @@ -46,6 +50,7 @@ module Fastlane build_number: last_testflight_build_number + 1, xcodeproj: "Runner.xcodeproj" ) + UI.message("👉🏼 Build number incremented") # Install Cocoapods Actions::CocoapodsAction.run( @@ -54,6 +59,7 @@ module Fastlane integrate: true, podfile: "./Podfile" ) + UI.message("👉🏼 Pod got") # Set up code signing using match # Configures and runs `match` which manages code signing certificates and provisioning profiles for the project. @@ -61,13 +67,20 @@ module Fastlane # It uses the App Store Connect API key to access the App Store and increment the build number. # It then runs `gym` to build and sign the app using the selected provisioning profile, and finally, uses `pilot` to upload the app to TestFlight for beta testing. Actions::MatchAction.run( + api_key: api_key type: 'appstore', app_identifier: creds['app_identifier_extensions'], git_basic_authorization: Base64.strict_encode64(ENV["GIT_AUTHORIZATION"]), keychain_name: creds['temp_keychain_user'], keychain_password: creds['temp_keychain_password'], - api_key: api_key + git_url: creds['git_url'], + username: "leonmalo@sfr.fr", + team_id: "118579280", + team_name: "Jagger & Lewis", + team_name: "https://github.com/JaggerLewis/jl2022_cert.git", + storage_mode: "git", ) + UI.message("👉🏼 App signed") # Build and export app using Gym # Builds and packages an iOS app or framework for distribution to the App Store, TestFlight, or Enterprise distribution. @@ -80,6 +93,7 @@ module Fastlane provisioningProfiles: creds['provisioning_profiles'] } ) + UI.message("👉🏼 App built") # Upload build to App Store Connect using Pilot Actions::PilotAction.run( @@ -91,6 +105,7 @@ module Fastlane notify_external_testers: false, ipa: "./Runner.ipa" ) + UI.message("👉🏼 App uploaded") Actions::DeleteTempKeychainAction.run end -- 2.47.2 From dbc8c0fed6b242a2ca9b445498c1dfaec6f32509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 1 May 2023 21:21:11 +0200 Subject: [PATCH 15/24] feat: add logs and parameters to match --- .../fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index 4a3d2cd..06384cc 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -67,7 +67,7 @@ module Fastlane # It uses the App Store Connect API key to access the App Store and increment the build number. # It then runs `gym` to build and sign the app using the selected provisioning profile, and finally, uses `pilot` to upload the app to TestFlight for beta testing. Actions::MatchAction.run( - api_key: api_key + api_key: api_key, type: 'appstore', app_identifier: creds['app_identifier_extensions'], git_basic_authorization: Base64.strict_encode64(ENV["GIT_AUTHORIZATION"]), @@ -78,7 +78,7 @@ module Fastlane team_id: "118579280", team_name: "Jagger & Lewis", team_name: "https://github.com/JaggerLewis/jl2022_cert.git", - storage_mode: "git", + storage_mode: "git" ) UI.message("👉🏼 App signed") -- 2.47.2 From a43966d6f8cd04834edb31e7e91edbf28bfe855b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 1 May 2023 21:34:17 +0200 Subject: [PATCH 16/24] feat: add logs and parameters to pilot --- .../fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index 06384cc..2e15547 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -97,6 +97,10 @@ module Fastlane # Upload build to App Store Connect using Pilot Actions::PilotAction.run( + api_key: api_key, + username: "leonmalo@sfr.fr", + team_id: "118579280", + team_name: "Jagger & Lewis", apple_id: creds['developer_app_id'].to_s, app_identifier: creds['developer_app_identifier'].to_s, skip_waiting_for_build_processing: true, -- 2.47.2 From 296d7181ca0139e02729159180dda0576c3cfab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 1 May 2023 21:38:45 +0200 Subject: [PATCH 17/24] fix: change git_url label --- .../fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index 2e15547..ad0fe22 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -77,7 +77,7 @@ module Fastlane username: "leonmalo@sfr.fr", team_id: "118579280", team_name: "Jagger & Lewis", - team_name: "https://github.com/JaggerLewis/jl2022_cert.git", + git_url: "https://github.com/JaggerLewis/jl2022_cert.git", storage_mode: "git" ) UI.message("👉🏼 App signed") -- 2.47.2 From fa9de2881f9fa1633e5b963479b70030b7bee345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 1 May 2023 22:31:03 +0200 Subject: [PATCH 18/24] refactor: try to use method actions instead of classes --- .../ios_cd/actions/build_and_deploy_action.rb | 16 ++++++++-------- .../plugin/ios_cd/helper/ios_cd_helper.rb | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index ad0fe22..6274f50 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -26,7 +26,7 @@ module Fastlane UI.message("👉🏼 New keychain created") # Obtain App Store Connect API key - api_key = Actions::AppStoreConnectApiKeyAction.run( + api_key = Actions.app_store_connect_api_key.call( key_id: creds['apple_key_id'].to_s, issuer_id: creds['apple_issuer_id'].to_s, key_content: creds['apple_key_content'].to_s, @@ -36,7 +36,7 @@ module Fastlane UI.message("👉🏼 API Key formated") last_testflight_build_number = - Actions::LatestTestflightBuildNumberAction.run( + Actions.latest_testflight_build_number( api_key: api_key, team_id: "118579280", team_name: "Jagger & Lewis", @@ -46,14 +46,14 @@ module Fastlane ) + 1 # Increment build number for latest TestFlight build - Actions::IncrementBuildNumberAction.run( + Actions.increment_build_number( build_number: last_testflight_build_number + 1, xcodeproj: "Runner.xcodeproj" ) UI.message("👉🏼 Build number incremented") # Install Cocoapods - Actions::CocoapodsAction.run( + Actions.cocoapods( clean_install: true, clean: true, integrate: true, @@ -66,7 +66,7 @@ module Fastlane # The function takes the app's bundle identifier, an authorization token for the project's Git repository, and the name and password for a temporary keychain used to store the signing certificate. # It uses the App Store Connect API key to access the App Store and increment the build number. # It then runs `gym` to build and sign the app using the selected provisioning profile, and finally, uses `pilot` to upload the app to TestFlight for beta testing. - Actions::MatchAction.run( + Actions.match( api_key: api_key, type: 'appstore', app_identifier: creds['app_identifier_extensions'], @@ -84,7 +84,7 @@ module Fastlane # Build and export app using Gym # Builds and packages an iOS app or framework for distribution to the App Store, TestFlight, or Enterprise distribution. - Actions::GymAction.run( + Actions.gym( configuration: "Release", workspace: "Runner.xcworkspace", scheme: "your_schema", @@ -96,7 +96,7 @@ module Fastlane UI.message("👉🏼 App built") # Upload build to App Store Connect using Pilot - Actions::PilotAction.run( + Actions.pilot( api_key: api_key, username: "leonmalo@sfr.fr", team_id: "118579280", @@ -111,7 +111,7 @@ module Fastlane ) UI.message("👉🏼 App uploaded") - Actions::DeleteTempKeychainAction.run + Actions.deleteTemp_keychain end def self.description diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb index 308892f..c082c0a 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb @@ -8,7 +8,7 @@ module Fastlane # Define method to delete temporary keychain def self.delete_temp_keychain(name) if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db")) - Actions::DeleteKeychainAction.run( + Actions.delete_keychain( name: name ) end @@ -16,7 +16,7 @@ module Fastlane # Define method to create temporary keychain def self.create_temp_keychain(name, password) - Actions::CreateKeychainAction.run( + Actionz.create_keychain( name: name, password: password, unlock: false, -- 2.47.2 From 04e06cf1a72e1d951d115b34137b7256ff1df4bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 1 May 2023 22:37:50 +0200 Subject: [PATCH 19/24] refactor: specify class for actions --- .../ios_cd/actions/build_and_deploy_action.rb | 16 ++++++++-------- .../plugin/ios_cd/helper/ios_cd_helper.rb | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index 6274f50..4c611e1 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -26,7 +26,7 @@ module Fastlane UI.message("👉🏼 New keychain created") # Obtain App Store Connect API key - api_key = Actions.app_store_connect_api_key.call( + api_key = Fastlane::Actions.app_store_connect_api_key.call( key_id: creds['apple_key_id'].to_s, issuer_id: creds['apple_issuer_id'].to_s, key_content: creds['apple_key_content'].to_s, @@ -36,7 +36,7 @@ module Fastlane UI.message("👉🏼 API Key formated") last_testflight_build_number = - Actions.latest_testflight_build_number( + Fastlane::Actions.latest_testflight_build_number( api_key: api_key, team_id: "118579280", team_name: "Jagger & Lewis", @@ -46,14 +46,14 @@ module Fastlane ) + 1 # Increment build number for latest TestFlight build - Actions.increment_build_number( + Fastlane::Actions.increment_build_number( build_number: last_testflight_build_number + 1, xcodeproj: "Runner.xcodeproj" ) UI.message("👉🏼 Build number incremented") # Install Cocoapods - Actions.cocoapods( + Fastlane::Actions.cocoapods( clean_install: true, clean: true, integrate: true, @@ -66,7 +66,7 @@ module Fastlane # The function takes the app's bundle identifier, an authorization token for the project's Git repository, and the name and password for a temporary keychain used to store the signing certificate. # It uses the App Store Connect API key to access the App Store and increment the build number. # It then runs `gym` to build and sign the app using the selected provisioning profile, and finally, uses `pilot` to upload the app to TestFlight for beta testing. - Actions.match( + Fastlane::Actions.match( api_key: api_key, type: 'appstore', app_identifier: creds['app_identifier_extensions'], @@ -84,7 +84,7 @@ module Fastlane # Build and export app using Gym # Builds and packages an iOS app or framework for distribution to the App Store, TestFlight, or Enterprise distribution. - Actions.gym( + Fastlane::Actions.gym( configuration: "Release", workspace: "Runner.xcworkspace", scheme: "your_schema", @@ -96,7 +96,7 @@ module Fastlane UI.message("👉🏼 App built") # Upload build to App Store Connect using Pilot - Actions.pilot( + Fastlane::Actions.pilot( api_key: api_key, username: "leonmalo@sfr.fr", team_id: "118579280", @@ -111,7 +111,7 @@ module Fastlane ) UI.message("👉🏼 App uploaded") - Actions.deleteTemp_keychain + Fastlane::Actions.deleteTemp_keychain end def self.description diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb index c082c0a..3a76666 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb @@ -8,7 +8,7 @@ module Fastlane # Define method to delete temporary keychain def self.delete_temp_keychain(name) if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db")) - Actions.delete_keychain( + Fastlane::Actions.delete_keychain( name: name ) end @@ -16,7 +16,7 @@ module Fastlane # Define method to create temporary keychain def self.create_temp_keychain(name, password) - Actionz.create_keychain( + Fastlane::Actions.create_keychain( name: name, password: password, unlock: false, -- 2.47.2 From 9e685cae0e446856e5d666a2bb8c01013099f200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 1 May 2023 22:48:51 +0200 Subject: [PATCH 20/24] refactor: rollback in actions called in helper --- .../lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb index 3a76666..308892f 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb @@ -8,7 +8,7 @@ module Fastlane # Define method to delete temporary keychain def self.delete_temp_keychain(name) if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db")) - Fastlane::Actions.delete_keychain( + Actions::DeleteKeychainAction.run( name: name ) end @@ -16,7 +16,7 @@ module Fastlane # Define method to create temporary keychain def self.create_temp_keychain(name, password) - Fastlane::Actions.create_keychain( + Actions::CreateKeychainAction.run( name: name, password: password, unlock: false, -- 2.47.2 From 6e7befa0673d377aa96164d1ce4cf7bdea69843c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 1 May 2023 23:14:07 +0200 Subject: [PATCH 21/24] fix: remove call keyword --- .../fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index 4c611e1..ce83bda 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -26,7 +26,7 @@ module Fastlane UI.message("👉🏼 New keychain created") # Obtain App Store Connect API key - api_key = Fastlane::Actions.app_store_connect_api_key.call( + api_key = Fastlane::Actions.app_store_connect_api_key( key_id: creds['apple_key_id'].to_s, issuer_id: creds['apple_issuer_id'].to_s, key_content: creds['apple_key_content'].to_s, -- 2.47.2 From 1c6b04e51124db43c0d9c39bb35ac822ff723e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Tue, 2 May 2023 09:30:21 +0200 Subject: [PATCH 22/24] refactor: use other_action keyword to call native fastane actions --- .../ios_cd/actions/build_and_deploy_action.rb | 17 +++++++++-------- .../plugin/ios_cd/helper/ios_cd_helper.rb | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index ce83bda..40e069f 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -26,17 +26,18 @@ module Fastlane UI.message("👉🏼 New keychain created") # Obtain App Store Connect API key - api_key = Fastlane::Actions.app_store_connect_api_key( + api_key = other_action.app_store_connect_api_key( key_id: creds['apple_key_id'].to_s, issuer_id: creds['apple_issuer_id'].to_s, key_content: creds['apple_key_content'].to_s, duration: 1200, in_house: false ) + UI.message("👉🏼 API Key formated") last_testflight_build_number = - Fastlane::Actions.latest_testflight_build_number( + other_action.latest_testflight_build_number( api_key: api_key, team_id: "118579280", team_name: "Jagger & Lewis", @@ -46,14 +47,14 @@ module Fastlane ) + 1 # Increment build number for latest TestFlight build - Fastlane::Actions.increment_build_number( + other_action.increment_build_number( build_number: last_testflight_build_number + 1, xcodeproj: "Runner.xcodeproj" ) UI.message("👉🏼 Build number incremented") # Install Cocoapods - Fastlane::Actions.cocoapods( + other_action.cocoapods( clean_install: true, clean: true, integrate: true, @@ -66,7 +67,7 @@ module Fastlane # The function takes the app's bundle identifier, an authorization token for the project's Git repository, and the name and password for a temporary keychain used to store the signing certificate. # It uses the App Store Connect API key to access the App Store and increment the build number. # It then runs `gym` to build and sign the app using the selected provisioning profile, and finally, uses `pilot` to upload the app to TestFlight for beta testing. - Fastlane::Actions.match( + other_action.match( api_key: api_key, type: 'appstore', app_identifier: creds['app_identifier_extensions'], @@ -84,7 +85,7 @@ module Fastlane # Build and export app using Gym # Builds and packages an iOS app or framework for distribution to the App Store, TestFlight, or Enterprise distribution. - Fastlane::Actions.gym( + other_action.gym( configuration: "Release", workspace: "Runner.xcworkspace", scheme: "your_schema", @@ -96,7 +97,7 @@ module Fastlane UI.message("👉🏼 App built") # Upload build to App Store Connect using Pilot - Fastlane::Actions.pilot( + other_action.pilot( api_key: api_key, username: "leonmalo@sfr.fr", team_id: "118579280", @@ -111,7 +112,7 @@ module Fastlane ) UI.message("👉🏼 App uploaded") - Fastlane::Actions.deleteTemp_keychain + other_action.deleteTemp_keychain end def self.description diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb index 308892f..a0bf867 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb @@ -8,7 +8,7 @@ module Fastlane # Define method to delete temporary keychain def self.delete_temp_keychain(name) if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db")) - Actions::DeleteKeychainAction.run( + other_action.deelete_keychain.run( name: name ) end @@ -16,7 +16,7 @@ module Fastlane # Define method to create temporary keychain def self.create_temp_keychain(name, password) - Actions::CreateKeychainAction.run( + other_actions.create_keychain_action.run( name: name, password: password, unlock: false, -- 2.47.2 From b67a267ca5c4b75295bc825b75679373df1f5311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Tue, 2 May 2023 09:41:34 +0200 Subject: [PATCH 23/24] fix: rollback native actions calls in helper --- .../lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb index a0bf867..308892f 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb @@ -8,7 +8,7 @@ module Fastlane # Define method to delete temporary keychain def self.delete_temp_keychain(name) if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db")) - other_action.deelete_keychain.run( + Actions::DeleteKeychainAction.run( name: name ) end @@ -16,7 +16,7 @@ module Fastlane # Define method to create temporary keychain def self.create_temp_keychain(name, password) - other_actions.create_keychain_action.run( + Actions::CreateKeychainAction.run( name: name, password: password, unlock: false, -- 2.47.2 From e003011b9abadbf4b94efa0a1043c061f2a7622a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 15 May 2023 17:00:23 +0200 Subject: [PATCH 24/24] feat: Improved pipeline efficiency and adapted to new credentials template --- .../ios_cd/actions/build_and_deploy_action.rb | 49 ++++++++----- .../plugin/ios_cd/actions/promote_action.rb | 71 +++++++++++++++++++ .../plugin/ios_cd/helper/ios_cd_helper.rb | 28 +------- 3 files changed, 102 insertions(+), 46 deletions(-) create mode 100644 plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/promote_action.rb diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb index 40e069f..5e62d3a 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/build_and_deploy_action.rb @@ -21,8 +21,20 @@ module Fastlane creds = Helper::IosCdHelper.parseIosCredentials('.') UI.message("👉🏼 Credentials parsed.") - # Ensure temporary keychain exists - Helper::IosCdHelper.ensure_temp_keychain(creds['temp_keychain_user'], creds['temp_keychain_password']) + # Delete keychain if existing + if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db")) + other_action.delete_keychain( + name: creds['temp_keychain_user'].to_s + ) + end + + # Create keychain to store certifs + other_action.create_keychain( + name: creds['temp_keychain_user'].to_s, + password: creds['temp_keychain_password'].to_s, + unlock: false, + timeout: 0 + ) UI.message("👉🏼 New keychain created") # Obtain App Store Connect API key @@ -33,17 +45,16 @@ module Fastlane duration: 1200, in_house: false ) - UI.message("👉🏼 API Key formated") last_testflight_build_number = other_action.latest_testflight_build_number( api_key: api_key, - team_id: "118579280", - team_name: "Jagger & Lewis", + team_id: creds['team_id'].to_s, + team_name: creds['team_name'].to_s, platform: 'ios', app_identifier: creds['developer_app_identifier'].to_s, - username: "leonmalo@sfr.fr" + username: creds['username'].to_s ) + 1 # Increment build number for latest TestFlight build @@ -72,13 +83,13 @@ module Fastlane type: 'appstore', app_identifier: creds['app_identifier_extensions'], git_basic_authorization: Base64.strict_encode64(ENV["GIT_AUTHORIZATION"]), - keychain_name: creds['temp_keychain_user'], - keychain_password: creds['temp_keychain_password'], - git_url: creds['git_url'], - username: "leonmalo@sfr.fr", - team_id: "118579280", - team_name: "Jagger & Lewis", - git_url: "https://github.com/JaggerLewis/jl2022_cert.git", + keychain_name: creds['temp_keychain_user'].to_s, + keychain_password: creds['temp_keychain_password'].to_s, + git_url: creds['git_url'].to_s, + username: creds['username'].to_s, + team_id: creds['team_id'].to_s, + team_name: creds['team_name'].to_s, + git_url: creds['git_url'].to_s, storage_mode: "git" ) UI.message("👉🏼 App signed") @@ -88,7 +99,6 @@ module Fastlane other_action.gym( configuration: "Release", workspace: "Runner.xcworkspace", - scheme: "your_schema", export_method: "app-store", export_options: { provisioningProfiles: creds['provisioning_profiles'] @@ -99,9 +109,6 @@ module Fastlane # Upload build to App Store Connect using Pilot other_action.pilot( api_key: api_key, - username: "leonmalo@sfr.fr", - team_id: "118579280", - team_name: "Jagger & Lewis", apple_id: creds['developer_app_id'].to_s, app_identifier: creds['developer_app_identifier'].to_s, skip_waiting_for_build_processing: true, @@ -110,9 +117,13 @@ module Fastlane notify_external_testers: false, ipa: "./Runner.ipa" ) - UI.message("👉🏼 App uploaded") - other_action.deleteTemp_keychain + # Delete keychain if existing + if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db")) + other_action.delete_keychain( + name: creds['temp_keychain_user'] + ) + end end def self.description diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/promote_action.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/promote_action.rb new file mode 100644 index 0000000..de15c0b --- /dev/null +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/actions/promote_action.rb @@ -0,0 +1,71 @@ +require 'fastlane/action' +require_relative '../helper/ios_cd_helper' + +module Fastlane + module Actions + class PromoteAction < Action + def self.run(params) + + UI.message("⌛️ Promoting to Store in external test..") + + # Decrypt the keys archive and Extract the keys archive + Helper::IosCdHelper.decrypt_ios_keys('.') + UI.message("👉🏼 Credentials decrypted.") + + # Retrieve credentials + creds = Helper::IosCdHelper.parseIosCredentials('.') + UI.message("👉🏼 Credentials parsed.") + + # Obtain App Store Connect API key + api_key = other_action.app_store_connect_api_key( + key_id: creds['apple_key_id'].to_s, + issuer_id: creds['apple_issuer_id'].to_s, + key_content: creds['apple_key_content'].to_s, + duration: 1200, + in_house: false + ) + UI.message("👉🏼 API Key formated") + + # Upload build to App Store Connect using Pilot + other_action.pilot( + api_key: api_key, + apple_id: creds['developer_app_id'].to_s, + app_identifier: creds['developer_app_identifier'].to_s, + skip_waiting_for_build_processing: false, + distribute_only: true, + skip_submission: true, + distribute_external: true, + notify_external_testers: true, + groups: [ + "Bêta externe", + ], + app_platform:'ios', + ) + + end + + def self.description + "Testflight and AppStore deployment plugin for Fastlane, simplifying the build and deployment porcess to internal, external, and production channels, and promoting builds for testing." + end + + def self.authors + ["SAS Wyatt Studio"] + end + + def self.return_value + end + + def self.details + "The Fastlane Testflight / Appstore deloyment action streamlines the build and deployment to internal, external and production channels. Allow you to promote builds on testflight beta tests." + end + + def self.available_options + [] + end + + def self.is_supported?(platform) + [:ios].include?(platform) + end + end + end +end diff --git a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb index 308892f..db2d2b9 100644 --- a/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb +++ b/plugins/fastlane-plugin-ios_cd/lib/fastlane/plugin/ios_cd/helper/ios_cd_helper.rb @@ -5,31 +5,6 @@ require 'fastlane_core/ui/ui' module Fastlane module Helper class IosCdHelper - # Define method to delete temporary keychain - def self.delete_temp_keychain(name) - if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db")) - Actions::DeleteKeychainAction.run( - name: name - ) - end - end - - # Define method to create temporary keychain - def self.create_temp_keychain(name, password) - Actions::CreateKeychainAction.run( - name: name, - password: password, - unlock: false, - timeout: 0 - ) - end - - # Define method to ensure that temporary keychain exists - def self.ensure_temp_keychain(name, password) - delete_temp_keychain(name) - create_temp_keychain(name, password) - end - # Check if a parameter is set or not def self.is_set(variable) str_variable = variable @@ -40,8 +15,7 @@ module Fastlane # Decrypts ios credentials def self.decrypt_ios_keys(ios_directory) # Define the GPG command with options - # gpg_command = "gpg --quiet --batch --yes --decrypt --passphrase=#{ENV['IOS_KEYS_SECRET_PASSPHRASE']} \ - gpg_command = "gpg --quiet --batch --yes --decrypt --passphrase=toto1234 \ + gpg_command = "gpg --quiet --batch --yes --decrypt --passphrase=#{ENV['IOS_KEYS_SECRET_PASSPHRASE']} \ --output #{ios_directory}/ios_keys.zip #{ios_directory}/ios_keys.zip.gpg" # Execute the GPG command using system -- 2.47.2