fastlane-plugin-wpmreleasetoolkit 6.0.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_firebase_test.rb +31 -4
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb +9 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb +14 -9
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +3 -2
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb +58 -10
- data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +1 -1
- metadata +2 -16
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d68a9310585fca22170859bab407386c1bf42287036832a08bdd0e55c3027522
         | 
| 4 | 
            +
              data.tar.gz: 297c23c5ffb14516663422be411ad163f16ce6620e88c5216bf76e8649350bb1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ca46edc69be727e82bd611707d1ed2f49efdeee160709712909ea48d7da03b6518bdff0bbbd8fd8bd3e5a75c1f1b770e353a71d0fadb654f66941b33a0262aec
         | 
| 7 | 
            +
              data.tar.gz: c043ac3b847ef8d5bc37a94803227dc8f39579ac3f7ec6957377969f5143e2a80c4e7eef8b04debba54a70439ca48d0f7cbaabcc598f3f9dc0b58bea896e35dc
         | 
| @@ -3,8 +3,9 @@ require 'securerandom' | |
| 3 3 | 
             
            module Fastlane
         | 
| 4 4 | 
             
              module Actions
         | 
| 5 5 | 
             
                module SharedValues
         | 
| 6 | 
            -
                  FIREBASE_TEST_RESULT = :FIREBASE_TEST_LOG_FILE
         | 
| 6 | 
            +
                  FIREBASE_TEST_RESULT = :FIREBASE_TEST_LOG_FILE # FirebaseTestLabResult object, for internal consumption
         | 
| 7 7 | 
             
                  FIREBASE_TEST_LOG_FILE_PATH = :FIREBASE_TEST_LOG_FILE_PATH
         | 
| 8 | 
            +
                  FIREBASE_TEST_MORE_DETAILS_URL = :FIREBASE_TEST_MORE_DETAILS_URL
         | 
| 8 9 | 
             
                end
         | 
| 9 10 |  | 
| 10 11 | 
             
                class AndroidFirebaseTestAction < Action
         | 
| @@ -45,13 +46,20 @@ module Fastlane | |
| 45 46 | 
             
                      key_file_path: params[:key_file]
         | 
| 46 47 | 
             
                    )
         | 
| 47 48 |  | 
| 48 | 
            -
                     | 
| 49 | 
            +
                    Fastlane::Actions.lane_context[SharedValues::FIREBASE_TEST_MORE_DETAILS_URL] = result.more_details_url
         | 
| 49 50 |  | 
| 50 | 
            -
                     | 
| 51 | 
            +
                    if result.success?
         | 
| 52 | 
            +
                      UI.success 'Firebase Tests Complete'
         | 
| 53 | 
            +
                      return true
         | 
| 54 | 
            +
                    else
         | 
| 55 | 
            +
                      ui_method = params[:crash_on_test_failure] ? :test_failure! : :error
         | 
| 56 | 
            +
                      FastlaneCore::UI.send(ui_method, "Firebase Tests failed – more information can be found at #{result.more_details_url}")
         | 
| 57 | 
            +
                      return false
         | 
| 58 | 
            +
                    end
         | 
| 51 59 | 
             
                  end
         | 
| 52 60 |  | 
| 53 61 | 
             
                  # Fastlane doesn't eagerly validate options for us, so we'll do it first to have control over
         | 
| 54 | 
            -
                  # when they're  | 
| 62 | 
            +
                  # when they're evaluated.
         | 
| 55 63 | 
             
                  def self.validate_options(params)
         | 
| 56 64 | 
             
                    available_options
         | 
| 57 65 | 
             
                      .reject { |opt| opt.optional || !opt.default_value.nil? }
         | 
| @@ -180,9 +188,28 @@ module Fastlane | |
| 180 188 | 
             
                        optional: true,
         | 
| 181 189 | 
             
                        type: String
         | 
| 182 190 | 
             
                      ),
         | 
| 191 | 
            +
                      FastlaneCore::ConfigItem.new(
         | 
| 192 | 
            +
                        key: :crash_on_test_failure,
         | 
| 193 | 
            +
                        description: 'If set to `true` (the default), will stop fastlane with `test_failure!`. ' \
         | 
| 194 | 
            +
                          + 'If `false`, the action will return the test status, without interrupting the rest of your Fastlane run on failure, letting the caller handle the failure on their side',
         | 
| 195 | 
            +
                        optional: true,
         | 
| 196 | 
            +
                        type: Boolean,
         | 
| 197 | 
            +
                        default_value: true
         | 
| 198 | 
            +
                      ),
         | 
| 183 199 | 
             
                    ]
         | 
| 184 200 | 
             
                  end
         | 
| 185 201 |  | 
| 202 | 
            +
                  def self.output
         | 
| 203 | 
            +
                    [
         | 
| 204 | 
            +
                      ['FIREBASE_TEST_LOG_FILE_PATH', 'Path to the `output.log` file containing the logs or invoking the tests'],
         | 
| 205 | 
            +
                      ['FIREBASE_TEST_MORE_DETAILS_URL', 'URL to the Firebase Console dashboard showing the details of the test run (and failures, if any)'],
         | 
| 206 | 
            +
                    ]
         | 
| 207 | 
            +
                  end
         | 
| 208 | 
            +
             | 
| 209 | 
            +
                  def self.return_value
         | 
| 210 | 
            +
                    'True if the test succeeded, false if they failed'
         | 
| 211 | 
            +
                  end
         | 
| 212 | 
            +
             | 
| 186 213 | 
             
                  def self.authors
         | 
| 187 214 | 
             
                    ['Automattic']
         | 
| 188 215 | 
             
                  end
         | 
| @@ -14,6 +14,7 @@ module Fastlane | |
| 14 14 | 
             
                    # Replace full URLS to PRs/Issues with shorthand, because GitHub does not render them properly otherwise.
         | 
| 15 15 | 
             
                    release_notes.gsub!(%r{https://github.com/([^/]*/[^/]*)/(pulls?|issues?)/([0-9]*)}, '\1#\3')
         | 
| 16 16 | 
             
                    prerelease = params[:prerelease]
         | 
| 17 | 
            +
                    is_draft = params[:is_draft]
         | 
| 17 18 |  | 
| 18 19 | 
             
                    UI.message("Creating draft release #{version} in #{repository}.")
         | 
| 19 20 | 
             
                    # Verify assets
         | 
| @@ -28,7 +29,8 @@ module Fastlane | |
| 28 29 | 
             
                      target: params[:target],
         | 
| 29 30 | 
             
                      description: release_notes,
         | 
| 30 31 | 
             
                      assets: assets,
         | 
| 31 | 
            -
                      prerelease: prerelease
         | 
| 32 | 
            +
                      prerelease: prerelease,
         | 
| 33 | 
            +
                      is_draft: is_draft
         | 
| 32 34 | 
             
                    )
         | 
| 33 35 | 
             
                    UI.message('Done')
         | 
| 34 36 | 
             
                  end
         | 
| @@ -83,6 +85,12 @@ module Fastlane | |
| 83 85 | 
             
                                                   optional: true,
         | 
| 84 86 | 
             
                                                   default_value: false,
         | 
| 85 87 | 
             
                                                   is_string: false),
         | 
| 88 | 
            +
                      FastlaneCore::ConfigItem.new(key: :is_draft,
         | 
| 89 | 
            +
                                                   env_name: 'GHHELPER_CREATE_RELEASE_IS_DRAFT',
         | 
| 90 | 
            +
                                                   description: 'True to create the GitHub release as a draft (instead of publishing it immediately)',
         | 
| 91 | 
            +
                                                   optional: true,
         | 
| 92 | 
            +
                                                   default_value: true,
         | 
| 93 | 
            +
                                                   type: Boolean),
         | 
| 86 94 | 
             
                      Fastlane::Helper::GithubHelper.github_token_config_item,
         | 
| 87 95 | 
             
                    ]
         | 
| 88 96 | 
             
                  end
         | 
| @@ -11,7 +11,9 @@ module Fastlane | |
| 11 11 | 
             
                    UI.message "#{self.check_path(params[:orig_folder])} Original Screenshot Source: #{params[:orig_folder]}"
         | 
| 12 12 | 
             
                    UI.message "#{self.check_path(params[:metadata_folder])} Translation source: #{params[:metadata_folder]}"
         | 
| 13 13 |  | 
| 14 | 
            -
                    config = helper. | 
| 14 | 
            +
                    config = helper.read_config(params[:config_file])
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                    helper.check_fonts_installed!(config: config) unless params[:skip_font_check]
         | 
| 15 17 |  | 
| 16 18 | 
             
                    translationDirectories = subdirectories_for_path(params[:metadata_folder])
         | 
| 17 19 | 
             
                    imageDirectories = subdirectories_for_path(params[:orig_folder])
         | 
| @@ -141,31 +143,34 @@ module Fastlane | |
| 141 143 | 
             
                                                   env_name: 'PROMOSS_ORIG',
         | 
| 142 144 | 
             
                                                   description: 'The directory containing the original screenshots',
         | 
| 143 145 | 
             
                                                   optional: false,
         | 
| 144 | 
            -
                                                    | 
| 146 | 
            +
                                                   type: String),
         | 
| 145 147 | 
             
                      FastlaneCore::ConfigItem.new(key: :output_folder,
         | 
| 146 148 | 
             
                                                   env_name: 'PROMOSS_OUTPUT',
         | 
| 147 149 | 
             
                                                   description: 'The path of the folder to save the promo screenshots',
         | 
| 148 150 | 
             
                                                   optional: false,
         | 
| 149 | 
            -
                                                    | 
| 150 | 
            -
             | 
| 151 | 
            +
                                                   type: String),
         | 
| 151 152 | 
             
                      FastlaneCore::ConfigItem.new(key: :metadata_folder,
         | 
| 152 153 | 
             
                                                   env_name: 'PROMOSS_METADATA_FOLDER',
         | 
| 153 154 | 
             
                                                   description: 'The directory containing the translation data',
         | 
| 154 155 | 
             
                                                   optional: false,
         | 
| 155 | 
            -
                                                    | 
| 156 | 
            -
             | 
| 156 | 
            +
                                                   type: String),
         | 
| 157 157 | 
             
                      FastlaneCore::ConfigItem.new(key: :config_file,
         | 
| 158 158 | 
             
                                                   env_name: 'PROMOSS_CONFIG_FILE',
         | 
| 159 159 | 
             
                                                   description: 'The path to the file containing the promo screenshot configuration',
         | 
| 160 160 | 
             
                                                   optional: true,
         | 
| 161 | 
            -
                                                    | 
| 161 | 
            +
                                                   type: String,
         | 
| 162 162 | 
             
                                                   default_value: 'screenshots.json'),
         | 
| 163 | 
            -
             | 
| 164 163 | 
             
                      FastlaneCore::ConfigItem.new(key: :force,
         | 
| 165 164 | 
             
                                                   env_name: 'PROMOSS_FORCE_CREATION',
         | 
| 166 165 | 
             
                                                   description: 'Overwrite existing promo screenshots without asking first?',
         | 
| 167 166 | 
             
                                                   optional: true,
         | 
| 168 | 
            -
                                                    | 
| 167 | 
            +
                                                   type: Boolean,
         | 
| 168 | 
            +
                                                   default_value: false),
         | 
| 169 | 
            +
                      FastlaneCore::ConfigItem.new(key: :skip_font_check,
         | 
| 170 | 
            +
                                                   env_name: 'PROMOSS_SKIP_FONT_CHECK',
         | 
| 171 | 
            +
                                                   description: 'Skip the check verifying that needed fonts are installed and active',
         | 
| 172 | 
            +
                                                   optional: true,
         | 
| 173 | 
            +
                                                   type: Boolean,
         | 
| 169 174 | 
             
                                                   default_value: false),
         | 
| 170 175 | 
             
                    ]
         | 
| 171 176 | 
             
                  end
         | 
| @@ -119,15 +119,16 @@ module Fastlane | |
| 119 119 | 
             
                  # @param [String] description The text to use as the release's body / description (typically the release notes)
         | 
| 120 120 | 
             
                  # @param [Array<String>] assets List of file paths to attach as assets to the release
         | 
| 121 121 | 
             
                  # @param [TrueClass|FalseClass] prerelease Indicates if this should be created as a pre-release (i.e. for alpha/beta)
         | 
| 122 | 
            +
                  # @param [TrueClass|FalseClass] is_draft Indicates if this should be created as a draft release
         | 
| 122 123 | 
             
                  #
         | 
| 123 | 
            -
                  def create_release(repository:, version:, target: nil, description:, assets:, prerelease:)
         | 
| 124 | 
            +
                  def create_release(repository:, version:, target: nil, description:, assets:, prerelease:, is_draft:)
         | 
| 124 125 | 
             
                    release = client.create_release(
         | 
| 125 126 | 
             
                      repository,
         | 
| 126 127 | 
             
                      version, # tag name
         | 
| 127 128 | 
             
                      name: version, # release name
         | 
| 128 129 | 
             
                      target_commitish: target || Git.open(Dir.pwd).log.first.sha,
         | 
| 129 | 
            -
                      draft: true,
         | 
| 130 130 | 
             
                      prerelease: prerelease,
         | 
| 131 | 
            +
                      draft: is_draft,
         | 
| 131 132 | 
             
                      body: description
         | 
| 132 133 | 
             
                    )
         | 
| 133 134 | 
             
                    assets.each do |file_path|
         | 
| @@ -7,11 +7,11 @@ rescue LoadError | |
| 7 7 | 
             
            end
         | 
| 8 8 | 
             
            require 'json'
         | 
| 9 9 | 
             
            require 'tempfile'
         | 
| 10 | 
            +
            require 'open3'
         | 
| 10 11 | 
             
            require 'optparse'
         | 
| 11 12 | 
             
            require 'pathname'
         | 
| 12 13 | 
             
            require 'progress_bar'
         | 
| 13 14 | 
             
            require 'parallel'
         | 
| 14 | 
            -
            require 'jsonlint'
         | 
| 15 15 | 
             
            require 'chroma'
         | 
| 16 16 | 
             
            require 'securerandom'
         | 
| 17 17 |  | 
| @@ -32,17 +32,65 @@ module Fastlane | |
| 32 32 | 
             
                    UI.user_error!('`drawText` not found – install it using `brew install automattic/build-tools/drawText`.') unless system('command -v drawText')
         | 
| 33 33 | 
             
                  end
         | 
| 34 34 |  | 
| 35 | 
            -
                  def  | 
| 35 | 
            +
                  def read_config(configFilePath)
         | 
| 36 36 | 
             
                    configFilePath = resolve_path(configFilePath)
         | 
| 37 37 |  | 
| 38 38 | 
             
                    begin
         | 
| 39 | 
            -
                       | 
| 40 | 
            -
             | 
| 41 | 
            -
                       | 
| 42 | 
            -
                       | 
| 43 | 
            -
             | 
| 39 | 
            +
                      # NOTE: While JSON is a subset of YAML and thus YAML.load_file would technically cover both cases at once, in practice
         | 
| 40 | 
            +
                      # `JSON.parse` is more lenient with JSON files than `YAML.load_file` is — especially, it accepts `// comments` in the
         | 
| 41 | 
            +
                      # JSON file, despite this not being allowed in the spec — hence why we still try with `JSON.parse` for `.json` files.
         | 
| 42 | 
            +
                      return File.extname(configFilePath) == '.json' ? JSON.parse(File.read(configFilePath)) : YAML.load_file(configFilePath)
         | 
| 43 | 
            +
                    rescue StandardError => e
         | 
| 44 | 
            +
                      UI.error(e)
         | 
| 45 | 
            +
                      UI.user_error!('Invalid JSON/YAML configuration. Please lint your config file to check for syntax errors.')
         | 
| 46 | 
            +
                    end
         | 
| 47 | 
            +
                  end
         | 
| 44 48 |  | 
| 45 | 
            -
             | 
| 49 | 
            +
                  # Checks that all required fonts are installed
         | 
| 50 | 
            +
                  #  - Visits the JSON config to find all the stylesheets referenced in it
         | 
| 51 | 
            +
                  #  - For each stylesheet, extract the first font of each `font-family` attribute found
         | 
| 52 | 
            +
                  #  - Finally, for each of those fonts, check that they exist and are activated.
         | 
| 53 | 
            +
                  #
         | 
| 54 | 
            +
                  # @param [Hash] config The promo screenshots configuration, as returned by #read_config
         | 
| 55 | 
            +
                  # @raise [UserError] Raises if at least one font is missing.
         | 
| 56 | 
            +
                  #
         | 
| 57 | 
            +
                  def check_fonts_installed!(config:)
         | 
| 58 | 
            +
                    # Find all stylesheets in the config
         | 
| 59 | 
            +
                    all_stylesheets = ([config['stylesheet']] + config['entries'].flat_map do |entry|
         | 
| 60 | 
            +
                      entry['attachments']&.map { |att| att['stylesheet'] }
         | 
| 61 | 
            +
                    end).compact.uniq
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                    # Parse the first font in each `font-family` attribute found in all found CSS files.
         | 
| 64 | 
            +
                    # Only the first in each `font-family` font list matters, as others are fallbacks we don't want to use anyway.
         | 
| 65 | 
            +
                    font_families = all_stylesheets.flat_map do |s|
         | 
| 66 | 
            +
                      File.readlines(s).flat_map do |line|
         | 
| 67 | 
            +
                        attr = line.match(/font-family: (.*);/)&.captures&.first
         | 
| 68 | 
            +
                        attr.split(',').first.strip.gsub(/'(.*)'/, '\1').gsub(/"(.*)"/, '\1') unless attr.nil?
         | 
| 69 | 
            +
                      end
         | 
| 70 | 
            +
                    end.compact.uniq
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                    # Verify that all fonts exists and are active—using a small swift script as there's no nice CLI for that
         | 
| 73 | 
            +
                    swift_script = <<~SWIFT
         | 
| 74 | 
            +
                      import AppKit
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                      var exitCode: Int32 = 0
         | 
| 77 | 
            +
                      for fontName in CommandLine.arguments.dropFirst() {
         | 
| 78 | 
            +
                          if NSFont(name: fontName, size: NSFont.systemFontSize) != nil {
         | 
| 79 | 
            +
                              print(" ✅ Font \\"\\(fontName)\\" found and active")
         | 
| 80 | 
            +
                          } else {
         | 
| 81 | 
            +
                              print(" ❌ Font \\"\\(fontName)\\" not found, it is either not installed or disabled. Please install it using FontBook first.")
         | 
| 82 | 
            +
                              exitCode = 1
         | 
| 83 | 
            +
                          }
         | 
| 84 | 
            +
                      }
         | 
| 85 | 
            +
                      exit(exitCode)
         | 
| 86 | 
            +
                    SWIFT
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                    Tempfile.create(['fonts-check-', '.swift']) do |f|
         | 
| 89 | 
            +
                      f.write(swift_script)
         | 
| 90 | 
            +
                      f.close
         | 
| 91 | 
            +
                      oe, s = Open3.capture2e('/usr/bin/env', 'xcrun', 'swift', f.path, *font_families)
         | 
| 92 | 
            +
                      UI.command_output(oe)
         | 
| 93 | 
            +
                      UI.user_error!('Some fonts required by your stylesheets are missing. Please install them and try again.') unless s.success?
         | 
| 46 94 | 
             
                    end
         | 
| 47 95 | 
             
                  end
         | 
| 48 96 |  | 
| @@ -343,8 +391,8 @@ module Fastlane | |
| 343 391 | 
             
                  def open_image(path)
         | 
| 344 392 | 
             
                    path = resolve_path(path)
         | 
| 345 393 |  | 
| 346 | 
            -
                    Magick::Image.read(path) | 
| 347 | 
            -
                       | 
| 394 | 
            +
                    Magick::Image.read(path) do |image|
         | 
| 395 | 
            +
                      image.background_color = 'transparent'
         | 
| 348 396 | 
             
                    end.first
         | 
| 349 397 | 
             
                  end
         | 
| 350 398 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: fastlane-plugin-wpmreleasetoolkit
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 6. | 
| 4 | 
            +
              version: 6.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Automattic
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2022- | 
| 11 | 
            +
            date: 2022-12-14 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         | 
| @@ -80,20 +80,6 @@ dependencies: | |
| 80 80 | 
             
                - - "~>"
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 82 | 
             
                    version: '1.3'
         | 
| 83 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            -
              name: jsonlint
         | 
| 85 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            -
                requirements:
         | 
| 87 | 
            -
                - - "~>"
         | 
| 88 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            -
                    version: '0.3'
         | 
| 90 | 
            -
              type: :runtime
         | 
| 91 | 
            -
              prerelease: false
         | 
| 92 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            -
                requirements:
         | 
| 94 | 
            -
                - - "~>"
         | 
| 95 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            -
                    version: '0.3'
         | 
| 97 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 98 84 | 
             
              name: nokogiri
         | 
| 99 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         |