Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Commit

Permalink
Added "--track_promote_to" option to supply for promoting APK betwe…
Browse files Browse the repository at this point in the history
…en tracks (fastlane#4562)
  • Loading branch information
sschendel authored and Andrea Falcone committed May 12, 2016
1 parent b28097c commit 8e965af
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
6 changes: 6 additions & 0 deletions supply/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ You can add changelog files under the `changelogs/` directory for each locale. T
└── 100100.txt
```

## Track Promotion

A common Play publishing scenario might involve uploading an APK version to a test track, testing it, and finally promoting that version to production.

This can be done using the `--track_promote_to` parameter. The `--track_promote_to` parameter works with the `--track` parameter to command the Play API to promote existing Play track APK version(s) (those active on the track identified by the `--track` param value) to a new track (`--track_promote_to` value).

## Tips

### [`fastlane`](https://fastlane.tools) Toolchain
Expand Down
12 changes: 12 additions & 0 deletions supply/lib/supply/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ def update_track(track, rollout, apk_version_code)
track_body)
end

# Get list of version codes for track
def track_version_codes(track)
ensure_active_edit!

result = android_publisher.get_track(
current_package_name,
current_edit.id,
track)

return result.version_codes
end

def update_apk_listing_for_language(apk_listing)
ensure_active_edit!

Expand Down
16 changes: 13 additions & 3 deletions supply/lib/supply/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module Supply
class Options
def self.available_options
valid_tracks = %w(production beta alpha rollout)
@options ||= [
FastlaneCore::ConfigItem.new(key: :package_name,
env_name: "SUPPLY_PACKAGE_NAME",
Expand All @@ -13,10 +14,10 @@ def self.available_options
FastlaneCore::ConfigItem.new(key: :track,
short_option: "-a",
env_name: "SUPPLY_TRACK",
description: "The Track to upload the Application to: production, beta, alpha or rollout",
description: "The Track to upload the Application to: #{valid_tracks.join(', ')}",
default_value: 'production',
verify_block: proc do |value|
available = %w(production beta alpha rollout)
available = valid_tracks
UI.user_error! "Invalid value '#{value}', must be #{available.join(', ')}" unless available.include? value
end),
FastlaneCore::ConfigItem.new(key: :rollout,
Expand Down Expand Up @@ -111,7 +112,16 @@ def self.available_options
optional: true,
description: "Whether to skip uploading SCREENSHOTS",
is_string: false,
default_value: false)
default_value: false),
FastlaneCore::ConfigItem.new(key: :track_promote_to,
env_name: "SUPPLY_TRACK_PROMOTE_TO",
optional: true,
description: "The Track to promote to: #{valid_tracks.join(', ')}",
verify_block: proc do |value|
available = valid_tracks
UI.user_error! "Invalid value '#{value}', must be #{available.join(', ')}" unless available.include? value
end)

]
end
end
Expand Down
10 changes: 10 additions & 0 deletions supply/lib/supply/uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,21 @@ def perform_upload

upload_binaries unless Supply.config[:skip_upload_apk]

promote_track if Supply.config[:track_promote_to]

UI.message("Uploading all changes to Google Play...")
client.commit_current_edit!
UI.success("Successfully finished the upload to Google Play")
end

def promote_track
version_codes = client.track_version_codes(Supply.config[:track])
client.update_track(Supply.config[:track], 1.0, nil)
version_codes.each do |apk_version_code|
client.update_track(Supply.config[:track_promote_to], 1.0, apk_version_code)
end
end

def upload_changelogs(language)
client.apks_version_codes.each do |apk_version_code|
upload_changelog(language, apk_version_code)
Expand Down

0 comments on commit 8e965af

Please sign in to comment.