Class: Supply::Uploader
- Inherits:
-
Object
- Object
- Supply::Uploader
- Defined in:
- supply/lib/supply/uploader.rb
Instance Method Summary collapse
- #perform_upload ⇒ Object
- #promote_track ⇒ Object
- #upload_binaries ⇒ Object
- #upload_changelog(language, apk_version_code) ⇒ Object
- #upload_changelogs(language) ⇒ Object
- #upload_images(language) ⇒ Object
- #upload_metadata(language, listing) ⇒ Object
- #upload_screenshots(language) ⇒ Object
- #verify_config! ⇒ Object
Instance Method Details
#perform_upload ⇒ Object
3 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 |
# File 'supply/lib/supply/uploader.rb', line 3 def perform_upload FastlaneCore::PrintTable.print_values(config: Supply.config, hide_keys: [:issuer], mask_keys: [:json_key_data], title: "Summary for supply #{Fastlane::VERSION}") client.begin_edit(package_name: Supply.config[:package_name]) verify_config! if UI.user_error!("Could not find folder #{}") unless File.directory?() all_languages.each do |language| next if language.start_with?('.') # e.g. . or .. or hidden folders UI.("Preparing to upload for language '#{language}'...") listing = client.listing_for_language(language) (language, listing) unless Supply.config[:skip_upload_metadata] upload_images(language) unless Supply.config[:skip_upload_images] upload_screenshots(language) unless Supply.config[:skip_upload_screenshots] upload_changelogs(language) unless Supply.config[:skip_upload_metadata] end end upload_binaries unless Supply.config[:skip_upload_apk] promote_track if Supply.config[:track_promote_to] if Supply.config[:validate_only] UI.("Validating all changes with Google Play...") client.validate_current_edit! UI.success("Successfully validated the upload to Google Play") else UI.("Uploading all changes to Google Play...") client.commit_current_edit! UI.success("Successfully finished the upload to Google Play") end end |
#promote_track ⇒ Object
47 48 49 50 51 52 53 |
# File 'supply/lib/supply/uploader.rb', line 47 def promote_track version_codes = client.track_version_codes(Supply.config[:track]) # the actual value passed for the rollout argument does not matter because it will be ignored by the Google Play API # but it has to be between 0.0 and 1.0 to pass the validity check. So we are passing the default value 0.1 client.update_track(Supply.config[:track], 0.1, nil) client.update_track(Supply.config[:track_promote_to], Supply.config[:rollout] || 0.1, version_codes) end |
#upload_binaries ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'supply/lib/supply/uploader.rb', line 113 def upload_binaries apk_paths = [Supply.config[:apk]] unless (apk_paths = Supply.config[:apk_paths]) apk_paths.compact! apk_version_codes = [] apk_paths.each do |apk_path| apk_version_codes.push(upload_binary_data(apk_path)) end mapping_paths = [Supply.config[:mapping]] unless (mapping_paths = Supply.config[:mapping_paths]) mapping_paths.zip(apk_version_codes).each do |mapping_path, version_code| if mapping_path client.upload_mapping(mapping_path, version_code) end end # Only update tracks if we have version codes # Updating a track with empty version codes can completely clear out a track update_track(apk_version_codes) unless apk_version_codes.empty? end |
#upload_changelog(language, apk_version_code) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'supply/lib/supply/uploader.rb', line 61 def upload_changelog(language, apk_version_code) path = File.join(, language, Supply::CHANGELOGS_FOLDER_NAME, "#{apk_version_code}.txt") if File.exist?(path) UI.("Updating changelog for code version '#{apk_version_code}' and language '#{language}'...") apk_listing = ApkListing.new(File.read(path, encoding: 'UTF-8'), language, apk_version_code) client.update_apk_listing_for_language(apk_listing) end end |
#upload_changelogs(language) ⇒ Object
55 56 57 58 59 |
# File 'supply/lib/supply/uploader.rb', line 55 def upload_changelogs(language) client.apks_version_codes.each do |apk_version_code| upload_changelog(language, apk_version_code) end end |
#upload_images(language) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'supply/lib/supply/uploader.rb', line 83 def upload_images(language) Supply::IMAGES_TYPES.each do |image_type| search = File.join(, language, Supply::IMAGES_FOLDER_NAME, image_type) + ".#{IMAGE_FILE_EXTENSIONS}" path = Dir.glob(search, File::FNM_CASEFOLD).last next unless path UI.("Uploading image file #{path}...") client.upload_image(image_path: File.(path), image_type: image_type, language: language) end end |
#upload_metadata(language, listing) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'supply/lib/supply/uploader.rb', line 70 def (language, listing) Supply::AVAILABLE_METADATA_FIELDS.each do |key| path = File.join(, language, "#{key}.txt") listing.send("#{key}=".to_sym, File.read(path, encoding: 'UTF-8')) if File.exist?(path) end begin listing.save rescue Encoding::InvalidByteSequenceError => ex = (ex. || '').capitalize UI.user_error!("Metadata must be UTF-8 encoded. #{}") end end |
#upload_screenshots(language) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'supply/lib/supply/uploader.rb', line 96 def upload_screenshots(language) Supply::SCREENSHOT_TYPES.each do |screenshot_type| search = File.join(, language, Supply::IMAGES_FOLDER_NAME, screenshot_type, "*.#{IMAGE_FILE_EXTENSIONS}") paths = Dir.glob(search, File::FNM_CASEFOLD) next unless paths.count > 0 client.clear_screenshots(image_type: screenshot_type, language: language) paths.sort.each do |path| UI.("Uploading screenshot #{path}...") client.upload_image(image_path: File.(path), image_type: screenshot_type, language: language) end end end |
#verify_config! ⇒ Object
41 42 43 44 45 |
# File 'supply/lib/supply/uploader.rb', line 41 def verify_config! unless || Supply.config[:apk] || Supply.config[:apk_paths] || (Supply.config[:track] && Supply.config[:track_promote_to]) UI.user_error!("No local metadata, apks, or track to promote were found, make sure to run `fastlane supply init` to setup supply") end end |