Skip to content

Instantly share code, notes, and snippets.

@firegate666
Last active June 8, 2021 08:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save firegate666/9c6a0139a2efe6996a2ef8c1b31e7b94 to your computer and use it in GitHub Desktop.
Save firegate666/9c6a0139a2efe6996a2ef8c1b31e7b94 to your computer and use it in GitHub Desktop.
Example of how to upload app previews from an ordered structure the apple app store by using Fatland and Spaceship
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:ios)
platform :ios do
lane :upload_video do
fastlane_require 'spaceship'
Spaceship::ConnectAPI.login()
app = Spaceship::ConnectAPI::App.find("com.example.my-app")
app_version = app.get_edit_app_store_version(platform:Spaceship::ConnectAPI::Platform::IOS)
localizations = app_version.get_app_store_version_localizations
# iterate all locales for this app
localizations.each do |localization|
puts "Locale: #{localization.locale}"
preview_sets = localization.get_app_preview_sets
preview_sets.each do |preview_set|
puts "\t#{preview_set.preview_type} #{preview_set.app_previews.size}"
end
# iterate all preview types for this locale
Spaceship::ConnectAPI::AppPreviewSet::PreviewType::ALL.each do |preview_type|
UI.message("Process preview type #{preview_type}")
# find the preview set for this type
preview_set = preview_sets.find do |set|
set.preview_type == preview_type
end
# create preview set if it does not exist yet
if preview_set.nil?
UI.message("Skipping #{preview_type}; not create first in app store")
next
#preview_set = localization.create_app_preview_set(attributes: {
# previewType: preview_type
#})
end
# delete all existing previews
if !preview_set.app_previews.empty? && UI.confirm("Delete existing previews?")
preview_set.app_previews.each do |app_preview|
UI.message("Deleting #{app_preview.id}")
app_preview.delete!
UI.message("Deleted #{app_preview.id}")
end
end
# upload all previews for this localization and type
if UI.confirm("Upload new previews?")
video_dir = "app_previews/#{localization.locale}/#{preview_type}/"
if !Dir.exists?(video_dir)
UI.message("Video directory #{video_dir} does not exist; skipping")
next
end
Dir.foreach(video_dir) do |filename|
next if filename == '.' or filename == '..'
path = File.absolute_path("#{video_dir}#{filename}")
UI.message("Upload video #{path}")
preview_set.upload_preview(path: path, wait_for_processing: false)
end # for foreach
end # if upload previews
end # foreach all preview types
end # foreach localizations
end # lane
end # platform do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment