Skip to content

Instantly share code, notes, and snippets.

@OdNairy
Last active June 2, 2019 19:43
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save OdNairy/13dc5132ae3a59dde372114224645484 to your computer and use it in GitHub Desktop.
Save OdNairy/13dc5132ae3a59dde372114224645484 to your computer and use it in GitHub Desktop.
Wait build to be processed and update changelog afterwards. fastlane 2.125+ required.
require 'spaceship'
module Fastlane
module Actions
module SharedValues
UPDATE_TF_CHANGELOG_CUSTOM_VALUE = :UPDATE_TF_CHANGELOG_CUSTOM_VALUE
end
class UpdateTfDataAction < Action
def self.run(params)
# fastlane will take care of reading in the parameter and fetching the environment variable:
UI.message "Parameter app version: #{params[:app_version]}"
UI.message "Parameter build version: #{params[:build_version]}"
UI.message "Parameter changelog: #{params[:changelog].to_json}"
app_version = params[:app_version]
build_version = params[:build_version]
app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
team_id = CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_id)
Spaceship::Tunes.login()
Spaceship::Tunes.select_team(team_id: team_id)
app = Spaceship::ConnectAPI::App.find("com.facemetrics.reader.ios")
@build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: app.id, app_version: app_version, build_version: build_version, return_spaceship_testflight_build: false)
puts @build
puts @build.beta_app_review_submission
@client = @build.client
localization = @build.get_beta_build_localizations.detect{|b| b.locale == "en-US" }
if localization != nil
@client.patch_beta_build_localizations(localization_id: localization.id, attributes: {"whatsNew": params[:changelog]})
end
UI.message("Your build #{@build} sucessfully processed")
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"A short description with <= 80 characters of what this action does"
end
def self.details
# Optional:
# this is your chance to provide a more detailed description of this action
"You can use this action to do cool things..."
end
def self.available_options
# Define all options your action supports.
# Below a few examples
[
FastlaneCore::ConfigItem.new(key: :app_version,
env_name: "FL_UPDATE_TF_DATA_APP_VERSION",
description: "Application version to wait for"),
FastlaneCore::ConfigItem.new(key: :build_version,
env_name: "FL_UPDATE_TF_DATA_BUILD_VERSION",
description: "Build version to wait for"),
FastlaneCore::ConfigItem.new(key: :changelog,
env_name: "FL_UPDATE_TF_DATA_CHANGELOG",
description: "Update changelog for concrete Testflight build")
]
end
def self.output
# Define the shared values you are going to provide
# Example
[
['UPDATE_TF_CHANGELOG_CUSTOM_VALUE', 'A description of what this value contains']
]
end
def self.return_value
# If your method provides a return value, you can describe here what it does
end
def self.authors
# So no one will ever forget your contribution to fastlane :) You are awesome btw!
["github/OdNairy"]
end
def self.is_supported?(platform)
platform == :ios
end
end
end
end
@OdNairy
Copy link
Author

OdNairy commented Jun 2, 2019

Updated action to support latest ConnectAPI methods. Requires fastlane 2.125+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment