From e02c69d2acd3555273b8155232a70c6eb719b917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 24 Apr 2023 11:58:18 +0200 Subject: [PATCH 1/9] init android plugin (#1) --- .../.github/workflows/test.yml | 24 +++ plugins/fastlane-plugin-android_cd/.gitignore | 12 ++ plugins/fastlane-plugin-android_cd/.rspec | 5 + .../fastlane-plugin-android_cd/.rubocop.yml | 188 ++++++++++++++++++ .../fastlane-plugin-android_cd/.travis.yml | 4 + plugins/fastlane-plugin-android_cd/Gemfile | 6 + plugins/fastlane-plugin-android_cd/LICENSE | 21 ++ plugins/fastlane-plugin-android_cd/README.md | 52 +++++ plugins/fastlane-plugin-android_cd/Rakefile | 9 + .../fastlane-plugin-android_cd.gemspec | 36 ++++ .../fastlane/Fastfile | 3 + .../fastlane/Pluginfile | 1 + .../lib/fastlane/plugin/android_cd.rb | 16 ++ .../android_cd/actions/android_cd_action.rb | 47 +++++ .../android_cd/helper/android_cd_helper.rb | 16 ++ .../lib/fastlane/plugin/android_cd/version.rb | 5 + .../spec/android_cd_action_spec.rb | 9 + .../spec/spec_helper.rb | 15 ++ 18 files changed, 469 insertions(+) create mode 100644 plugins/fastlane-plugin-android_cd/.github/workflows/test.yml create mode 100644 plugins/fastlane-plugin-android_cd/.gitignore create mode 100644 plugins/fastlane-plugin-android_cd/.rspec create mode 100644 plugins/fastlane-plugin-android_cd/.rubocop.yml create mode 100644 plugins/fastlane-plugin-android_cd/.travis.yml create mode 100644 plugins/fastlane-plugin-android_cd/Gemfile create mode 100644 plugins/fastlane-plugin-android_cd/LICENSE create mode 100644 plugins/fastlane-plugin-android_cd/README.md create mode 100644 plugins/fastlane-plugin-android_cd/Rakefile create mode 100644 plugins/fastlane-plugin-android_cd/fastlane-plugin-android_cd.gemspec create mode 100644 plugins/fastlane-plugin-android_cd/fastlane/Fastfile create mode 100644 plugins/fastlane-plugin-android_cd/fastlane/Pluginfile create mode 100644 plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd.rb create mode 100644 plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/android_cd_action.rb create mode 100644 plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb create mode 100644 plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/version.rb create mode 100644 plugins/fastlane-plugin-android_cd/spec/android_cd_action_spec.rb create mode 100644 plugins/fastlane-plugin-android_cd/spec/spec_helper.rb diff --git a/plugins/fastlane-plugin-android_cd/.github/workflows/test.yml b/plugins/fastlane-plugin-android_cd/.github/workflows/test.yml new file mode 100644 index 0000000..f1e0b0c --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/.github/workflows/test.yml @@ -0,0 +1,24 @@ +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 diff --git a/plugins/fastlane-plugin-android_cd/.gitignore b/plugins/fastlane-plugin-android_cd/.gitignore new file mode 100644 index 0000000..b7e3986 --- /dev/null +++ b/plugins/fastlane-plugin-android_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-android_cd/.rspec b/plugins/fastlane-plugin-android_cd/.rspec new file mode 100644 index 0000000..e1f89b5 --- /dev/null +++ b/plugins/fastlane-plugin-android_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-android_cd/.rubocop.yml b/plugins/fastlane-plugin-android_cd/.rubocop.yml new file mode 100644 index 0000000..fc36fbb --- /dev/null +++ b/plugins/fastlane-plugin-android_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-android_cd/.travis.yml b/plugins/fastlane-plugin-android_cd/.travis.yml new file mode 100644 index 0000000..3b35e45 --- /dev/null +++ b/plugins/fastlane-plugin-android_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-android_cd/Gemfile b/plugins/fastlane-plugin-android_cd/Gemfile new file mode 100644 index 0000000..7e8dba6 --- /dev/null +++ b/plugins/fastlane-plugin-android_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-android_cd/LICENSE b/plugins/fastlane-plugin-android_cd/LICENSE new file mode 100644 index 0000000..c1a9462 --- /dev/null +++ b/plugins/fastlane-plugin-android_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-android_cd/README.md b/plugins/fastlane-plugin-android_cd/README.md new file mode 100644 index 0000000..bc0cac8 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/README.md @@ -0,0 +1,52 @@ +# android_cd plugin + +[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-android_cd) + +## Getting Started + +This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-android_cd`, add it to your project by running: + +```bash +fastlane add_plugin android_cd +``` + +## About android_cd + +Google Play Store deployment plugin for Fastlane, simplifying the build and deployment process to internal, beta, alpha, 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-android_cd/Rakefile b/plugins/fastlane-plugin-android_cd/Rakefile new file mode 100644 index 0000000..094ebe2 --- /dev/null +++ b/plugins/fastlane-plugin-android_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-android_cd/fastlane-plugin-android_cd.gemspec b/plugins/fastlane-plugin-android_cd/fastlane-plugin-android_cd.gemspec new file mode 100644 index 0000000..5950ed6 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/fastlane-plugin-android_cd.gemspec @@ -0,0 +1,36 @@ +lib = File.expand_path("lib", __dir__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'fastlane/plugin/android_cd/version' + +Gem::Specification.new do |spec| + spec.name = 'fastlane-plugin-android_cd' + spec.version = Fastlane::AndroidCd::VERSION + spec.author = 'Malo Léon' + spec.email = 'malo.leon@wyatt-studio.fr' + + spec.summary = 'Google Play Store deployment plugin for Fastlane, simplifying the build and deployment process to internal, beta, alpha, and production channels, and promoting builds for testing.' + # spec.homepage = "https://github.com//fastlane-plugin-android_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-android_cd/fastlane/Fastfile b/plugins/fastlane-plugin-android_cd/fastlane/Fastfile new file mode 100644 index 0000000..fdbc775 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/fastlane/Fastfile @@ -0,0 +1,3 @@ +lane :test do + android_cd +end diff --git a/plugins/fastlane-plugin-android_cd/fastlane/Pluginfile b/plugins/fastlane-plugin-android_cd/fastlane/Pluginfile new file mode 100644 index 0000000..e0576b0 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/fastlane/Pluginfile @@ -0,0 +1 @@ +# Autogenerated by fastlane diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd.rb new file mode 100644 index 0000000..196367b --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd.rb @@ -0,0 +1,16 @@ +require 'fastlane/plugin/android_cd/version' + +module Fastlane + module AndroidCd + # 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::AndroidCd.all_classes.each do |current| + require current +end diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/android_cd_action.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/android_cd_action.rb new file mode 100644 index 0000000..71f4c8f --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/android_cd_action.rb @@ -0,0 +1,47 @@ +require 'fastlane/action' +require_relative '../helper/android_cd_helper' + +module Fastlane + module Actions + class AndroidCdAction < Action + def self.run(params) + UI.message("The android_cd plugin is working!") + end + + def self.description + "Google Play Store deployment plugin for Fastlane, simplifying the build and deployment process to internal, beta, alpha, 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 Google Play Store deployment plugin streamlines the build and deployment process to internal, beta, alpha, and production channels, simplifying the process of distributing builds for testing. With its advanced promotion functionality, it also enables easy promotion of builds to higher beta testing phases, helping you get your app to market faster." + end + + def self.available_options + [ + # FastlaneCore::ConfigItem.new(key: :your_option, + # env_name: "ANDROID_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-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb new file mode 100644 index 0000000..72f8fb1 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_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 AndroidCdHelper + # class methods that you define here become available in your action + # as `Helper::AndroidCdHelper.your_method` + # + def self.show_message + UI.message("Hello from the android_cd plugin helper!") + end + end + end +end diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/version.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/version.rb new file mode 100644 index 0000000..2ecc613 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/version.rb @@ -0,0 +1,5 @@ +module Fastlane + module AndroidCd + VERSION = "0.1.0" + end +end diff --git a/plugins/fastlane-plugin-android_cd/spec/android_cd_action_spec.rb b/plugins/fastlane-plugin-android_cd/spec/android_cd_action_spec.rb new file mode 100644 index 0000000..dac01eb --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/spec/android_cd_action_spec.rb @@ -0,0 +1,9 @@ +describe Fastlane::Actions::AndroidCdAction do + describe '#run' do + it 'prints a message' do + expect(Fastlane::UI).to receive(:message).with("The android_cd plugin is working!") + + Fastlane::Actions::AndroidCdAction.run(nil) + end + end +end diff --git a/plugins/fastlane-plugin-android_cd/spec/spec_helper.rb b/plugins/fastlane-plugin-android_cd/spec/spec_helper.rb new file mode 100644 index 0000000..78b2fad --- /dev/null +++ b/plugins/fastlane-plugin-android_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/android_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 a7052e57b569ec8a971e2639bcccb10105743a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 24 Apr 2023 12:50:36 +0200 Subject: [PATCH 2/9] feat: implement first version of android cd pipeline (#1) --- .../android_cd/actions/android_cd_action.rb | 47 ------------- .../android_cd/actions/build_and_deploy.rb | 67 +++++++++++++++++++ .../android_cd/helper/android_cd_helper.rb | 26 ++++--- 3 files changed, 85 insertions(+), 55 deletions(-) delete mode 100644 plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/android_cd_action.rb create mode 100644 plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/android_cd_action.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/android_cd_action.rb deleted file mode 100644 index 71f4c8f..0000000 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/android_cd_action.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'fastlane/action' -require_relative '../helper/android_cd_helper' - -module Fastlane - module Actions - class AndroidCdAction < Action - def self.run(params) - UI.message("The android_cd plugin is working!") - end - - def self.description - "Google Play Store deployment plugin for Fastlane, simplifying the build and deployment process to internal, beta, alpha, 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 Google Play Store deployment plugin streamlines the build and deployment process to internal, beta, alpha, and production channels, simplifying the process of distributing builds for testing. With its advanced promotion functionality, it also enables easy promotion of builds to higher beta testing phases, helping you get your app to market faster." - end - - def self.available_options - [ - # FastlaneCore::ConfigItem.new(key: :your_option, - # env_name: "ANDROID_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-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb new file mode 100644 index 0000000..cd0b48d --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb @@ -0,0 +1,67 @@ +require 'fastlane/action' +require_relative '../helper/android_cd_helper' + +module Fastlane + module Actions + class AndroidCdAction < Action + def self.run(params) + + # Decrypt the keys archive and Extract the keys archive + Helper::AppcenterHelper.decrypt_android_keys('../') + + # Clean the project before building + gradle(task: "clean") + + # Set the build number based on the number of commits + build_number = number_of_commits() + + # Build the Android App Bundle + gradle( + task: "bundle", + build_type: "Release", + print_command: true, + properties: { + "android.injected.version.code" => build_number, + } + ) + + # Upload the Android App Bundle to the Play Store + upload_to_play_store( + track: 'internal', + json_key: './service_account_key.json', + aab: '../build/app/outputs/bundle/release/app-release.aab', + skip_upload_metadata: true, + skip_upload_images: true, + skip_upload_screenshots: true, + release_status: "draft", + version_code: build_number, + package_name: 'com.jaggerlewis.jl_2022' + ) + end + + def self.description + "Google Play Store deployment plugin for Fastlane, simplifying the build and deployment process to internal, beta, alpha, 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 Google Play Store deployment plugin streamlines the build and deployment process to internal, beta, alpha, and production channels, simplifying the process of distributing builds for testing. With its advanced promotion functionality, it also enables easy promotion of builds to higher beta testing phases, helping you get your app to market faster." + end + + def self.available_options + [ + ] + end + + def self.is_supported?(platform) + [:android].include?(platform) + end + end + end +end diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb index 72f8fb1..5563430 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb @@ -1,15 +1,25 @@ require 'fastlane_core/ui/ui' module Fastlane - UI = FastlaneCore::UI unless Fastlane.const_defined?("UI") - - module Helper + module Helper class AndroidCdHelper - # class methods that you define here become available in your action - # as `Helper::AndroidCdHelper.your_method` - # - def self.show_message - UI.message("Hello from the android_cd plugin helper!") + def self.decrypt_android_keys(android_directory) + + # Define the GPG command with options + gpg_command = "gpg --quiet --batch --yes --decrypt --passphrase=#{ENV['ANDROID_KEYS_SECRET_PASSPHRASE']} \ + --output #{android_directory}/android_keys.zip #{android_directory}/android_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 #{android_directory} && mv #{android_directory}/android_keys/* #{android_directory}` + else + puts "Erreur lors de la décompression du fichier GPG" + end end end end -- 2.47.2 From 5deb1ff0c1e14d06897de8bb73a6da5c13de86e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 24 Apr 2023 13:59:47 +0200 Subject: [PATCH 3/9] build: add gemspec name (#1) --- plugins/fastlane-plugin-android_cd/Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fastlane-plugin-android_cd/Gemfile b/plugins/fastlane-plugin-android_cd/Gemfile index 7e8dba6..fcd3de1 100644 --- a/plugins/fastlane-plugin-android_cd/Gemfile +++ b/plugins/fastlane-plugin-android_cd/Gemfile @@ -1,6 +1,6 @@ source('https://rubygems.org') -gemspec +gemspec name: android_cd plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') eval_gemfile(plugins_path) if File.exist?(plugins_path) -- 2.47.2 From 7281754c7d9d21ee5a31683a57b50ddf4855cb90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 24 Apr 2023 14:20:41 +0200 Subject: [PATCH 4/9] fix: fix Helper class name (#1) --- plugins/fastlane-plugin-android_cd/Gemfile | 2 +- .../lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/fastlane-plugin-android_cd/Gemfile b/plugins/fastlane-plugin-android_cd/Gemfile index fcd3de1..89e0953 100644 --- a/plugins/fastlane-plugin-android_cd/Gemfile +++ b/plugins/fastlane-plugin-android_cd/Gemfile @@ -1,6 +1,6 @@ source('https://rubygems.org') -gemspec name: android_cd +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-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb index cd0b48d..ee63195 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb @@ -7,7 +7,7 @@ module Fastlane def self.run(params) # Decrypt the keys archive and Extract the keys archive - Helper::AppcenterHelper.decrypt_android_keys('../') + Helper::AndroidCdHelper.decrypt_android_keys('../') # Clean the project before building gradle(task: "clean") -- 2.47.2 From 3ba6468acdaec4fc1d96f611ce07ba39610aff48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 24 Apr 2023 14:42:49 +0200 Subject: [PATCH 5/9] fix: update android directory path (#1) --- .../lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb index ee63195..0f0988e 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb @@ -7,7 +7,7 @@ module Fastlane def self.run(params) # Decrypt the keys archive and Extract the keys archive - Helper::AndroidCdHelper.decrypt_android_keys('../') + Helper::AndroidCdHelper.decrypt_android_keys('.') # Clean the project before building gradle(task: "clean") -- 2.47.2 From df8a15dfa4838ef214dfaad8511bb128fb4c9ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 24 Apr 2023 15:32:31 +0200 Subject: [PATCH 6/9] fix: update fastlane actions calls (#1) --- .../plugin/android_cd/actions/build_and_deploy.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb index 0f0988e..d4d76d0 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb @@ -10,13 +10,13 @@ module Fastlane Helper::AndroidCdHelper.decrypt_android_keys('.') # Clean the project before building - gradle(task: "clean") + Fastlane::Actions.gradle(task: "clean") # Set the build number based on the number of commits - build_number = number_of_commits() + build_number = Fastlane::Actions.number_of_commits() # Build the Android App Bundle - gradle( + Fastlane::Actions.gradle( task: "bundle", build_type: "Release", print_command: true, @@ -26,7 +26,7 @@ module Fastlane ) # Upload the Android App Bundle to the Play Store - upload_to_play_store( + Fastlane::Actions.upload_to_play_store( track: 'internal', json_key: './service_account_key.json', aab: '../build/app/outputs/bundle/release/app-release.aab', -- 2.47.2 From 28fe4921f50b1e91edef4746f679053d934e8a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 24 Apr 2023 16:31:55 +0200 Subject: [PATCH 7/9] feat: add test parameter (#1) --- plugins/fastlane-plugin-android_cd/Gemfile | 2 +- .../fastlane/Fastfile | 2 +- .../android_cd/actions/build_and_deploy.rb | 23 +++++++++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/plugins/fastlane-plugin-android_cd/Gemfile b/plugins/fastlane-plugin-android_cd/Gemfile index 89e0953..a11d1f3 100644 --- a/plugins/fastlane-plugin-android_cd/Gemfile +++ b/plugins/fastlane-plugin-android_cd/Gemfile @@ -2,5 +2,5 @@ source('https://rubygems.org') gemspec -plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') +plugins_path = 'fastlane/Pluginfile' eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/plugins/fastlane-plugin-android_cd/fastlane/Fastfile b/plugins/fastlane-plugin-android_cd/fastlane/Fastfile index fdbc775..c2bba1b 100644 --- a/plugins/fastlane-plugin-android_cd/fastlane/Fastfile +++ b/plugins/fastlane-plugin-android_cd/fastlane/Fastfile @@ -1,3 +1,3 @@ lane :test do - android_cd + android_cd(beta_type: "internal") end diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb index d4d76d0..c980207 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb @@ -1,10 +1,24 @@ require 'fastlane/action' require_relative '../helper/android_cd_helper' +def is_set variable + str_variable = variable + str_variable = variable.strip if variable.class.to_s == "String" + variable && !(str_variable.nil? || str_variable.empty?) +end + module Fastlane module Actions class AndroidCdAction < Action def self.run(params) + + # Check parameters + unless 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 Google Play Store in #{params[:beta_type]}") # Decrypt the keys archive and Extract the keys archive Helper::AndroidCdHelper.decrypt_android_keys('.') @@ -27,7 +41,7 @@ module Fastlane # Upload the Android App Bundle to the Play Store Fastlane::Actions.upload_to_play_store( - track: 'internal', + track: params[:beta_type], json_key: './service_account_key.json', aab: '../build/app/outputs/bundle/release/app-release.aab', skip_upload_metadata: true, @@ -35,8 +49,9 @@ module Fastlane skip_upload_screenshots: true, release_status: "draft", version_code: build_number, - package_name: 'com.jaggerlewis.jl_2022' ) + + UI.success('🍺 Successfully build & deploy appbundle to Google Play Store') end def self.description @@ -56,6 +71,10 @@ module Fastlane def self.available_options [ + FastlaneCore::ConfigItem.new(key: :beta_type, + env_name: "ANDROID_CD_TEST_TYPE", + optional: false, + description: "Type of test (production, beta, alpha, internal)"), ] end -- 2.47.2 From d4896b44f745be1eb0366af8f3ac1ebd9ee683ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 24 Apr 2023 16:58:23 +0200 Subject: [PATCH 8/9] refactor: migrate is_set method in helper (#1) --- .../plugin/android_cd/actions/build_and_deploy.rb | 8 ++------ .../plugin/android_cd/helper/android_cd_helper.rb | 6 ++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb index c980207..7cad159 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb @@ -1,11 +1,7 @@ require 'fastlane/action' require_relative '../helper/android_cd_helper' -def is_set variable - str_variable = variable - str_variable = variable.strip if variable.class.to_s == "String" - variable && !(str_variable.nil? || str_variable.empty?) -end + module Fastlane module Actions @@ -13,7 +9,7 @@ module Fastlane def self.run(params) # Check parameters - unless is_set(params[:beta_type]) + unless Helper::AndroidCdHelper.is_set(params[:beta_type]) UI.error("Parameters beta_type cannot be null") puts "Error on beta type parameter" end diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb index 5563430..8b5b256 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb @@ -21,6 +21,12 @@ module Fastlane puts "Erreur lors de la décompression du fichier GPG" end end + + 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 end end end -- 2.47.2 From 7c1eb8772686862e78f4c26eee18518d6912fb6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 24 Apr 2023 17:13:44 +0200 Subject: [PATCH 9/9] styme: format file (#1) --- .../lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb index 7cad159..605d951 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb @@ -1,8 +1,6 @@ require 'fastlane/action' require_relative '../helper/android_cd_helper' - - module Fastlane module Actions class AndroidCdAction < Action -- 2.47.2