Implement support for AAB upload to store

This commit is contained in:
Jean-Philippe ANDRE 2019-07-08 16:13:44 +09:00
Родитель a4ebc2bf27
Коммит 4c55f10e02
6 изменённых файлов: 148 добавлений и 8 удалений

Просмотреть файл

@ -24,7 +24,7 @@ appcenter_upload(
api_token: "<appcenter token>", api_token: "<appcenter token>",
owner_name: "<your appcenter account name>", owner_name: "<your appcenter account name>",
app_name: "<your app name>", app_name: "<your app name>",
apk: "<path to android build binary>", apk: "<path to android build binary>", # Or aab: "<path to aab file>" for app bundles
notify_testers: true # Set to false if you don't want to notify testers of your new release (default: `false`) notify_testers: true # Set to false if you don't want to notify testers of your new release (default: `false`)
) )
``` ```
@ -35,6 +35,7 @@ The action parameters `api_token` and `owner_name` can also be omitted when thei
- `APPCENTER_OWNER_NAME` - Owner name - `APPCENTER_OWNER_NAME` - Owner name
- `APPCENTER_APP_NAME` - App name. If there is no app with such name, you will be prompted to create one - `APPCENTER_APP_NAME` - App name. If there is no app with such name, you will be prompted to create one
- `APPCENTER_DISTRIBUTE_APK` - Build release path for android build - `APPCENTER_DISTRIBUTE_APK` - Build release path for android build
- `APPCENTER_DISTRIBUTE_AAB` - Build release path for android app bundle build
- `APPCENTER_DISTRIBUTE_IPA` - Build release path for ios build - `APPCENTER_DISTRIBUTE_IPA` - Build release path for ios build
- `APPCENTER_DISTRIBUTE_DSYM` - Path to your symbols (app.dSYM.zip) file - `APPCENTER_DISTRIBUTE_DSYM` - Path to your symbols (app.dSYM.zip) file
- `APPCENTER_DISTRIBUTE_UPLOAD_DSYM_ONLY` - Flag to upload only the dSYM file to App Center - `APPCENTER_DISTRIBUTE_UPLOAD_DSYM_ONLY` - Flag to upload only the dSYM file to App Center

Просмотреть файл

@ -117,7 +117,8 @@ module Fastlane
file = [ file = [
params[:ipa], params[:ipa],
params[:apk] params[:apk],
params[:aab]
].detect { |e| !e.to_s.empty? } ].detect { |e| !e.to_s.empty? }
UI.user_error!("Couldn't find build file at path '#{file}'") unless file && File.exist?(file) UI.user_error!("Couldn't find build file at path '#{file}'") unless file && File.exist?(file)
@ -274,7 +275,7 @@ module Fastlane
default_value: Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH], default_value: Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH],
optional: true, optional: true,
type: String, type: String,
conflicting_options: [:ipa], conflicting_options: [:ipa, :aab],
conflict_block: proc do |value| conflict_block: proc do |value|
UI.user_error!("You can't use 'apk' and '#{value.key}' options in one run") UI.user_error!("You can't use 'apk' and '#{value.key}' options in one run")
end, end,
@ -283,13 +284,28 @@ module Fastlane
UI.user_error!("Only \".apk\" formats are allowed, you provided \"#{File.extname(value)}\"") unless accepted_formats.include? File.extname(value) UI.user_error!("Only \".apk\" formats are allowed, you provided \"#{File.extname(value)}\"") unless accepted_formats.include? File.extname(value)
end), end),
FastlaneCore::ConfigItem.new(key: :aab,
env_name: "APPCENTER_DISTRIBUTE_AAB",
description: "Build release path for android app bundle build",
default_value: Actions.lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH],
optional: true,
type: String,
conflicting_options: [:ipa, :apk],
conflict_block: proc do |value|
UI.user_error!("You can't use 'aab' and '#{value.key}' options in one run")
end,
verify_block: proc do |value|
accepted_formats = [".aab"]
UI.user_error!("Only \".aab\" formats are allowed, you provided \"#{File.extname(value)}\"") unless accepted_formats.include? File.extname(value)
end),
FastlaneCore::ConfigItem.new(key: :ipa, FastlaneCore::ConfigItem.new(key: :ipa,
env_name: "APPCENTER_DISTRIBUTE_IPA", env_name: "APPCENTER_DISTRIBUTE_IPA",
description: "Build release path for ios build", description: "Build release path for ios build",
default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH], default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH],
optional: true, optional: true,
type: String, type: String,
conflicting_options: [:apk], conflicting_options: [:apk, :aab],
conflict_block: proc do |value| conflict_block: proc do |value|
UI.user_error!("You can't use 'ipa' and '#{value.key}' options in one run") UI.user_error!("You can't use 'ipa' and '#{value.key}' options in one run")
end, end,
@ -451,6 +467,19 @@ module Fastlane
dsym: "./app.dSYM.zip", dsym: "./app.dSYM.zip",
release_notes: "release notes", release_notes: "release notes",
notify_testers: false notify_testers: false
)',
'appcenter_upload(
api_token: "...",
owner_name: "appcenter_owner",
app_name: "testing_app",
aab: "./app.aab",
destinations: "Alpha",
destination_type: "store",
build_number: "3",
version: "1.0.0",
mapping: "./mapping.txt",
release_notes: "release notes",
notify_testers: false
)' )'
] ]
end end

Просмотреть файл

@ -184,7 +184,7 @@ module Fastlane
options = {} options = {}
options[:upload_id] = upload_id options[:upload_id] = upload_id
# ipa field is used both for .apk and .ipa files # ipa field is used for .apk, .aab and .ipa files
options[:ipa] = Faraday::UploadIO.new(file, 'application/octet-stream') if file && File.exist?(file) options[:ipa] = Faraday::UploadIO.new(file, 'application/octet-stream') if file && File.exist?(file)
response = connection.post do |req| response = connection.post do |req|

Просмотреть файл

@ -1,5 +1,5 @@
module Fastlane module Fastlane
module Appcenter module Appcenter
VERSION = "1.1.0" VERSION = "1.1.1"
end end
end end

Просмотреть файл

@ -198,6 +198,22 @@ describe Fastlane::Actions::AppcenterUploadAction do
end.to raise_error("Couldn't find build file at path './nothing.apk'") end.to raise_error("Couldn't find build file at path './nothing.apk'")
end end
it "raises an error if given aab was not found" do
expect do
stub_check_app(200)
Fastlane::FastFile.new.parse("lane :test do
appcenter_upload({
api_token: 'xxx',
owner_name: 'owner',
app_name: 'app',
destinations: 'Testers',
destination_type: 'group',
aab: './nothing.aab'
})
end").runner.execute(:test)
end.to raise_error("Couldn't find build file at path './nothing.aab'")
end
it "raises an error if given ipa was not found" do it "raises an error if given ipa was not found" do
expect do expect do
stub_check_app(200) stub_check_app(200)
@ -229,6 +245,21 @@ describe Fastlane::Actions::AppcenterUploadAction do
end.to raise_error("Only \".apk\" formats are allowed, you provided \"\"") end.to raise_error("Only \".apk\" formats are allowed, you provided \"\"")
end end
it "raises an error if given file has invalid extension for aab" do
expect do
Fastlane::FastFile.new.parse("lane :test do
appcenter_upload({
api_token: 'xxx',
owner_name: 'owner',
app_name: 'app',
destinations: 'Testers',
destination_type: 'group',
aab: './spec/fixtures/appfiles/Appfile_empty'
})
end").runner.execute(:test)
end.to raise_error("Only \".aab\" formats are allowed, you provided \"\"")
end
it "raises an error if given file has invalid extension for ipa" do it "raises an error if given file has invalid extension for ipa" do
expect do expect do
Fastlane::FastFile.new.parse("lane :test do Fastlane::FastFile.new.parse("lane :test do
@ -260,6 +291,38 @@ describe Fastlane::Actions::AppcenterUploadAction do
end.to raise_error("You can't use 'ipa' and 'apk' options in one run") end.to raise_error("You can't use 'ipa' and 'apk' options in one run")
end end
it "raises an error if both aab and apk provided" do
expect do
Fastlane::FastFile.new.parse("lane :test do
appcenter_upload({
api_token: 'xxx',
owner_name: 'owner',
app_name: 'app',
destinations: 'Testers',
destination_type: 'group',
aab: './spec/fixtures/appfiles/aab_file_empty.aab',
apk: './spec/fixtures/appfiles/apk_file_empty.apk'
})
end").runner.execute(:test)
end.to raise_error("You can't use 'aab' and 'apk' options in one run")
end
it "raises an error if both aab and ipa provided" do
expect do
Fastlane::FastFile.new.parse("lane :test do
appcenter_upload({
api_token: 'xxx',
owner_name: 'owner',
app_name: 'app',
destinations: 'Testers',
destination_type: 'group',
ipa: './spec/fixtures/appfiles/ipa_file_empty.ipa',
apk: './spec/fixtures/appfiles/apk_file_empty.apk'
})
end").runner.execute(:test)
end.to raise_error("You can't use 'ipa' and 'apk' options in one run")
end
it "raises an error if destination type is not group or store" do it "raises an error if destination type is not group or store" do
expect do expect do
Fastlane::FastFile.new.parse("lane :test do Fastlane::FastFile.new.parse("lane :test do
@ -502,7 +565,7 @@ describe Fastlane::Actions::AppcenterUploadAction do
stub_create_release_upload(200) stub_create_release_upload(200)
stub_upload_build(200) stub_upload_build(200)
stub_update_release_upload(200, 'committed') stub_update_release_upload(200, 'committed')
stub_update_release(200) stub_update_release(200)
stub_get_destination(200) stub_get_destination(200)
stub_add_to_destination(200) stub_add_to_destination(200)
stub_get_release(200) stub_get_release(200)
@ -519,12 +582,34 @@ describe Fastlane::Actions::AppcenterUploadAction do
end").runner.execute(:test) end").runner.execute(:test)
end end
it "works with valid parameters for android app bundle" do
stub_check_app(200)
stub_create_release_upload(200)
stub_upload_build(200)
stub_update_release_upload(200, 'committed')
stub_update_release(200)
stub_get_destination(200)
stub_add_to_destination(200)
stub_get_release(200)
Fastlane::FastFile.new.parse("lane :test do
appcenter_upload({
api_token: 'xxx',
owner_name: 'owner',
app_name: 'app',
aab: './spec/fixtures/appfiles/aab_file_empty.aab',
destinations: 'Testers',
destination_type: 'group'
})
end").runner.execute(:test)
end
it "uses GRADLE_APK_OUTPUT_PATH as default for apk" do it "uses GRADLE_APK_OUTPUT_PATH as default for apk" do
stub_check_app(200) stub_check_app(200)
stub_create_release_upload(200) stub_create_release_upload(200)
stub_upload_build(200) stub_upload_build(200)
stub_update_release_upload(200, 'committed') stub_update_release_upload(200, 'committed')
stub_update_release(200) stub_update_release(200)
stub_get_destination(200) stub_get_destination(200)
stub_add_to_destination(200) stub_add_to_destination(200)
stub_get_release(200) stub_get_release(200)
@ -544,6 +629,31 @@ describe Fastlane::Actions::AppcenterUploadAction do
expect(values[:apk]).to eq('./spec/fixtures/appfiles/apk_file_empty.apk') expect(values[:apk]).to eq('./spec/fixtures/appfiles/apk_file_empty.apk')
end end
it "uses GRADLE_AAB_OUTPUT_PATH as default for aab" do
stub_check_app(200)
stub_create_release_upload(200)
stub_upload_build(200)
stub_update_release_upload(200, 'committed')
stub_update_release(200)
stub_get_destination(200)
stub_add_to_destination(200)
stub_get_release(200)
values = Fastlane::FastFile.new.parse("lane :test do
Actions.lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH] = './spec/fixtures/appfiles/aab_file_empty.aab'
appcenter_upload({
api_token: 'xxx',
owner_name: 'owner',
app_name: 'app',
destinations: 'Testers',
destination_type: 'group'
})
end").runner.execute(:test)
expect(values[:aab]).to eq('./spec/fixtures/appfiles/aab_file_empty.aab')
end
it "uses IPA_OUTPUT_PATH as default for ipa" do it "uses IPA_OUTPUT_PATH as default for ipa" do
stub_check_app(200) stub_check_app(200)
stub_create_release_upload(200) stub_create_release_upload(200)

0
spec/fixtures/appfiles/aab_file_empty.aab поставляемый Normal file
Просмотреть файл