fastlane/lib/fastlane/actions/set_changelog.rb in fastlane_hotfix-2.165.1 vs fastlane/lib/fastlane/actions/set_changelog.rb in fastlane_hotfix-2.187.0
- old
+ new
@@ -4,13 +4,15 @@
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.message("Using App Store Connect API token...")
- Spaceship::ConnectAPI.token = token
+ if (api_token = Spaceship::ConnectAPI::Token.from(hash: params[:api_key], filepath: params[:api_key_path]))
+ UI.message("Creating authorization token for App Store Connect API")
+ Spaceship::ConnectAPI.token = api_token
+ elsif !Spaceship::ConnectAPI.token.nil?
+ UI.message("Using existing authorization token for App Store Connect API")
else
UI.message("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.message("Login successful")
end
@@ -76,17 +78,10 @@
end
UI.success("👼 Successfully pushed the new changelog to for #{edit_version.version_string}")
end
- 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
-
def self.default_changelog_path
File.join(FastlaneCore::FastlaneFolder.path.to_s, 'changelog.txt')
end
#####################################################
@@ -109,21 +104,23 @@
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",
+ env_names: ["FL_SET_CHANGELOG_API_KEY_PATH", "APP_STORE_CONNECT_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",
+ env_names: ["FL_SET_CHANGELOG_API_KEY", "APP_STORE_CONNECT_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,
+ default_value: Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APP_STORE_CONNECT_API_KEY],
+ default_value_dynamic: true,
optional: true,
sensitive: true,
conflicting_options: [:api_key_path]),
FastlaneCore::ConfigItem.new(key: :app_identifier,
short_option: "-a",
@@ -150,10 +147,10 @@
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
+ skip_type_validation: true, # 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