Class: Fastlane::Actions::SetChangelogAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::SetChangelogAction
- Defined in:
- fastlane/lib/fastlane/actions/set_changelog.rb
Constant Summary
Constants inherited from Fastlane::Action
Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
Class Method Summary collapse
Methods inherited from Fastlane::Action
action_name, author, deprecated_notes, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text
Class Method Details
.api_token(params) ⇒ Object
81 82 83 84 85 86 |
# File 'fastlane/lib/fastlane/actions/set_changelog.rb', line 81 def self.api_token(params) params[:api_key] ||= Actions.lane_context[SharedValues::APP_STORE_CONNECT_API_KEY] api_token ||= Spaceship::ConnectAPI::Token.create(params[:api_key]) if params[:api_key] api_token ||= Spaceship::ConnectAPI::Token.from_json_file(params[:api_key_path]) if params[:api_key_path] return api_token end |
.authors ⇒ Object
184 185 186 |
# File 'fastlane/lib/fastlane/actions/set_changelog.rb', line 184 def self. ["KrauseFx"] end |
.available_options ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'fastlane/lib/fastlane/actions/set_changelog.rb', line 108 def self. user = CredentialsManager::AppfileConfig.try_fetch_value(:itunes_connect_id) user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id) [ FastlaneCore::ConfigItem.new(key: :api_key_path, env_name: "FL_SET_CHANGELOG_API_KEY_PATH", description: "Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file)", optional: true, conflicting_options: [:api_key], verify_block: proc do |value| UI.user_error!("Couldn't find API key JSON file at path '#{value}'") unless File.exist?(value) end), FastlaneCore::ConfigItem.new(key: :api_key, env_name: "FL_SET_CHANGELOG_API_KEY", description: "Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#use-return-value-and-pass-in-as-an-option)", type: Hash, optional: true, sensitive: true, conflicting_options: [:api_key_path]), FastlaneCore::ConfigItem.new(key: :app_identifier, short_option: "-a", env_name: "FASTLANE_APP_IDENTIFIER", description: "The bundle identifier of your app", code_gen_sensitive: true, default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier), default_value_dynamic: true), FastlaneCore::ConfigItem.new(key: :username, short_option: "-u", env_name: "FASTLANE_USERNAME", description: "Your Apple ID Username", optional: true, default_value: user, default_value_dynamic: true), FastlaneCore::ConfigItem.new(key: :version, env_name: "FL_SET_CHANGELOG_VERSION", description: "The version number to create/update", optional: true), FastlaneCore::ConfigItem.new(key: :changelog, env_name: "FL_SET_CHANGELOG_CHANGELOG", description: "Changelog text that should be uploaded to App Store Connect", optional: true), FastlaneCore::ConfigItem.new(key: :team_id, short_option: "-k", env_name: "FL_SET_CHANGELOG_TEAM_ID", description: "The ID of your App Store Connect team if you're in multiple teams", optional: true, is_string: false, # as we also allow integers, which we convert to strings anyway code_gen_sensitive: true, default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_id), default_value_dynamic: true, verify_block: proc do |value| ENV["FASTLANE_ITC_TEAM_ID"] = value.to_s end), FastlaneCore::ConfigItem.new(key: :team_name, short_option: "-e", env_name: "FL_SET_CHANGELOG_TEAM_NAME", description: "The name of your App Store Connect team if you're in multiple teams", optional: true, code_gen_sensitive: true, default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_name), default_value_dynamic: true, verify_block: proc do |value| ENV["FASTLANE_ITC_TEAM_NAME"] = value.to_s end), FastlaneCore::ConfigItem.new(key: :platform, env_name: "FL_SET_CHANGELOG_PLATFORM", description: "The platform of the app (ios, appletvos, mac)", default_value: "ios", verify_block: proc do |value| available = ['ios', 'appletvos', 'mac'] UI.user_error!("Invalid platform '#{value}', must be #{available.join(', ')}") unless available.include?(value) end) ] end |
.category ⇒ Object
199 200 201 |
# File 'fastlane/lib/fastlane/actions/set_changelog.rb', line 199 def self.category :app_store_connect end |
.default_changelog_path ⇒ Object
88 89 90 |
# File 'fastlane/lib/fastlane/actions/set_changelog.rb', line 88 def self.default_changelog_path File.join(FastlaneCore::FastlaneFolder.path.to_s, 'changelog.txt') end |
.description ⇒ Object
96 97 98 |
# File 'fastlane/lib/fastlane/actions/set_changelog.rb', line 96 def self.description "Set the changelog for all languages on App Store Connect" end |
.details ⇒ Object
100 101 102 103 104 105 106 |
# File 'fastlane/lib/fastlane/actions/set_changelog.rb', line 100 def self.details [ "This is useful if you have only one changelog for all languages.", "You can store the changelog in `#{default_changelog_path}` and it will automatically get loaded from there. This integration is useful if you support e.g. 10 languages and want to use the same \"What's new\"-text for all languages.", "Defining the version is optional. _fastlane_ will try to automatically detect it if you don't provide one." ].join("\n") end |
.example_code ⇒ Object
192 193 194 195 196 197 |
# File 'fastlane/lib/fastlane/actions/set_changelog.rb', line 192 def self.example_code [ 'set_changelog(changelog: "Changelog for all Languages")', 'set_changelog(app_identifier: "com.krausefx.app", version: "1.0", changelog: "Changelog for all Languages")' ] end |
.is_supported?(platform) ⇒ Boolean
188 189 190 |
# File 'fastlane/lib/fastlane/actions/set_changelog.rb', line 188 def self.is_supported?(platform) [:ios, :appletvos, :mac].include?(platform) end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'fastlane/lib/fastlane/actions/set_changelog.rb', line 4 def self.run(params) require 'spaceship' # Team selection passed though FASTLANE_ITC_TEAM_ID and FASTLANE_ITC_TEAM_NAME environment variables # Prompts select team if multiple teams and none specified if (token = self.api_token(params)) UI.("Using App Store Connect API token...") Spaceship::ConnectAPI.token = token else UI.("Login to App Store Connect (#{params[:username]})") Spaceship::ConnectAPI.login(params[:username], use_portal: false, use_tunes: true, tunes_team_id: params[:team_id], team_name: params[:team_name]) UI.("Login successful") end app = Spaceship::ConnectAPI::App.find(params[:app_identifier]) UI.user_error!("Couldn't find app with identifier #{params[:app_identifier]}") if app.nil? version_number = params[:version] platform = Spaceship::ConnectAPI::Platform.map(params[:platform]) unless version_number # Automatically fetch the latest version UI.("Fetching the latest version for this app") edit_version = app.get_edit_app_store_version(platform: platform) if edit_version version_number = edit_version.version_string else UI.("You have to specify a new version number: ") version_number = STDIN.gets.strip end end UI.("Going to update version #{version_number}") changelog = params[:changelog] unless changelog path = default_changelog_path UI.("Looking for changelog in '#{path}'...") if File.exist?(path) changelog = File.read(path) else UI.error("Couldn't find changelog.txt") UI.("Please enter the changelog here:") changelog = STDIN.gets end end UI.important("Going to update the changelog to:\n\n#{changelog}\n\n") edit_version = app.get_edit_app_store_version(platform: platform) if edit_version if edit_version.version_string != version_number # Version is already there, make sure it matches the one we want to create UI.("Changing existing version number from '#{edit_version.version_string}' to '#{version_number}'") edit_version = edit_version.update(attributes: { versionString: version_number }) else UI.("Updating changelog for existing version #{edit_version.version_string}") end else UI.("Creating the new version: #{version_number}") attributes = { versionString: version_number, platform: platform } edit_version = Spaceship::ConnectAPI.post_app_store_version(app_id: app.id, attributes: attributes).first end localizations = edit_version.get_app_store_version_localizations localizations.each do |localization| UI.("Updating changelog for the '#{localization.locale}'") localization.update(attributes: { whatsNew: changelog }) end UI.success("👼 Successfully pushed the new changelog to for #{edit_version.version_string}") end |