fastlane-plugin-taiwan_number_one 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c476927219f7b1a3dcc7a6b5028143512ade17422dabd2068c1e17ed3694e9d3
4
- data.tar.gz: c68e731269bfaa3dbe968aa439bc3259d2dfde16967ad3b7ebfa190eae36369e
3
+ metadata.gz: e643cce0efc7af0226a41196fe7e3440e69e91ee672b3c7b3eee306818376e30
4
+ data.tar.gz: eec2ccc3f94005558c87adfa0f342ba36b0185fa6ec1ec2439501b9c6225e9e5
5
5
  SHA512:
6
- metadata.gz: bf4d2fc1e683b7f2d7c39cedea1952342a89aae659c40095310ea1b6ba7cf6dc93febcc861157431229271a5727ffc48e2647299154ca5a84e4ca21b38a8c319
7
- data.tar.gz: 6f8868bbdad6f94983f435816ecd3f8fef9475f90e87a3ece2f49584538655fa53f81d63b38159105a03eb30d655962958e823248e724b864261d4afe766fb02
6
+ metadata.gz: 575f8b85689e0631509bcaa11c2c81a11844264f89293882dab29bf7e53078b9cb1dcc3aa4cf45b8eed13c82ec8dbebeb9def22941e3dacdf4afc5229c0e890d
7
+ data.tar.gz: bc7ac4a0bf65de66828f1bbfbd9e34774835a4a47c504244b2e548ca139be70b6ecab70b54004c09f8226a3af99ee00ebd64abbc46d317f629d44444b09f7bf0
data/README.md CHANGED
@@ -59,11 +59,23 @@ lane :release_decision do |options|
59
59
  taiwan_number_one(
60
60
  username: username,
61
61
  app_identifier: app_identifier,
62
- app_decision: options[:app_decision]
62
+ app_decision: options[:app_decision],
63
+ api_key: api_key
63
64
  )
64
65
  end
65
66
  ```
66
67
 
68
+ and this:
69
+ ```
70
+ desc "release App store version"
71
+ lane :release_app do
72
+ result = release_decision(app_decision: Fastlane::Actions::TaiwanNumberOneAction::DicisionType::RELEASE)
73
+ if result == Fastlane::Actions::TaiwanNumberOneAction::ActionResult::SUCCESS
74
+ # do your thing here!
75
+ end
76
+ end
77
+ ```
78
+
67
79
  or this:
68
80
  ```
69
81
  desc "reject App store version"
@@ -73,10 +85,7 @@ lane :reject_app do
73
85
  issuer_id: ENV["ISSUER_ID"],
74
86
  key_content: ENV["ASC_API_KEY"]
75
87
  )
76
- release_decision(
77
- app_decision: Fastlane::Actions::TaiwanNumberOneAction::DicisionType::REJECT,
78
- api_key: api_key
79
- )
88
+ release_decision(app_decision: Fastlane::Actions::TaiwanNumberOneAction::DicisionType::REJECT)
80
89
  end
81
90
  ```
82
91
 
@@ -126,6 +135,11 @@ team_name |The name of your App Store Connect team if you're in multiple tea
126
135
  api_key_path |Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file) |
127
136
  api_key |Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#use-return-value-and-pass-in-as-an-option) |
128
137
 
138
+ ## Action Return
139
+ `Fastlane::Actions::TaiwanNumberOneAction::ActionResult::SUCCESS`
140
+ or
141
+ `Fastlane::Actions::TaiwanNumberOneAction::ActionResult::DO_NOTHING`
142
+
129
143
  ## Run tests for this plugin
130
144
 
131
145
  Not supported right now.
@@ -10,70 +10,87 @@ module Fastlane
10
10
  REJECT = "reject"
11
11
  end
12
12
 
13
- def self.run(params)
14
- params[:api_key] ||= Actions.lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
15
-
16
- app_id = params.fetch(:app_identifier)
17
- username = params.fetch(:username)
18
- unless app_id && username
19
- UI.message("Could not find app_id and username.")
20
- return
21
- end
13
+ module ActionResult
14
+ SUCCESS = "Success"
15
+ DO_NOTHING = "Nothing has changed"
16
+ end
22
17
 
23
- token = self.api_token(params)
24
- if token
25
- UI.message("Using App Store Connect API token...")
26
- Spaceship::ConnectAPI.token = token
27
- else
28
- UI.message("Login to App Store Connect (#{params[:username]})")
29
- Spaceship::ConnectAPI.login(
30
- params[:username],
31
- use_portal: false,
32
- use_tunes: true,
33
- tunes_team_id: params[:team_id],
34
- team_name: params[:team_name]
35
- )
36
- UI.message("Login successful")
37
- end
18
+ def self.run(params)
19
+ begin
20
+ params[:api_key] ||= Actions.lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
38
21
 
39
- app = Spaceship::ConnectAPI::App.find(app_id)
40
- version = app.get_app_store_versions.first
41
- UI.message("app_store_state is #{version.app_store_state}")
42
- client ||= Spaceship::ConnectAPI
43
- platform ||= Spaceship::ConnectAPI::Platform::IOS
44
- filter = {
45
- appStoreState: [
46
- Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::PENDING_DEVELOPER_RELEASE
47
- ].join(","),
48
- platform: platform
49
- }
50
- app_store_version = app.get_app_store_versions(client: client, filter: filter, includes: "appStoreVersionSubmission")
51
- .sort_by { |v| Gem::Version.new(v.version_string) }
52
- .last
53
- if app_store_version
54
- version_string = app_store_version.version_string
55
- state = app_store_version.app_store_state
56
- UI.message("version #{version_string} is #{state}")
57
- unless state == Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::PENDING_DEVELOPER_RELEASE
58
- UI.message("AppStoreState is not PENDING_DEVELOPER_RELEASE")
22
+ app_id = params.fetch(:app_identifier)
23
+ username = params.fetch(:username)
24
+ unless app_id && username
25
+ UI.message("Could not find app_id and username.")
59
26
  return
60
27
  end
61
- decision = params[:app_decision]
62
- decision ||= fetch_decision
63
- case decision
64
- when DicisionType::RELEASE
65
- UI.message("decision is release")
66
- release_version_if_possible(app: app, app_store_version: app_store_version)
67
- when DicisionType::REJECT
68
- UI.message("decision is reject")
69
- reject_version_if_possible(app: app, app_store_version: app_store_version)
28
+
29
+ token = self.api_token(params)
30
+ if token
31
+ UI.message("Using App Store Connect API token...")
32
+ Spaceship::ConnectAPI.token = token
70
33
  else
34
+ UI.message("Login to App Store Connect (#{params[:username]})")
35
+ Spaceship::ConnectAPI.login(
36
+ params[:username],
37
+ use_portal: false,
38
+ use_tunes: true,
39
+ tunes_team_id: params[:team_id],
40
+ team_name: params[:team_name]
41
+ )
42
+ UI.message("Login successful")
43
+ end
44
+
45
+ app = Spaceship::ConnectAPI::App.find(app_id)
46
+ version = app.get_app_store_versions.first
47
+ UI.message("app_store_state is #{version.app_store_state}")
48
+ client ||= Spaceship::ConnectAPI
49
+ platform ||= Spaceship::ConnectAPI::Platform::IOS
50
+ filter = {
51
+ appStoreState: [
52
+ Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::PENDING_DEVELOPER_RELEASE
53
+ ].join(","),
54
+ platform: platform
55
+ }
56
+ app_store_version = app.get_app_store_versions(client: client, filter: filter, includes: "appStoreVersionSubmission")
57
+ .sort_by { |v| Gem::Version.new(v.version_string) }
58
+ .last
59
+ if app_store_version
60
+ version_string = app_store_version.version_string
61
+ state = app_store_version.app_store_state
62
+ UI.message("version #{version_string} is #{state}")
63
+ unless state == Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::PENDING_DEVELOPER_RELEASE
64
+ UI.message("AppStoreState is not PENDING_DEVELOPER_RELEASE")
65
+ return
66
+ end
67
+ decision = params[:app_decision]
71
68
  decision ||= fetch_decision
69
+
70
+ result = ActionResult::DO_NOTHING
71
+ case decision
72
+ when DicisionType::RELEASE
73
+ UI.message("decision is release")
74
+ result = release_version_if_possible(app: app, app_store_version: app_store_version)
75
+ when DicisionType::REJECT
76
+ UI.message("decision is reject")
77
+ result = reject_version_if_possible(app: app, app_store_version: app_store_version)
78
+ else
79
+ UI.user_error!("App's decision must be release or reject")
80
+ result = ActionResult::DO_NOTHING
81
+ end
82
+
83
+ UI.message("The taiwan_number_one plugin action is finished!")
84
+ return result
85
+ else
86
+ UI.message("no pending release version exist.")
87
+ UI.message("The taiwan_number_one plugin action is finished!")
88
+ return ActionResult::DO_NOTHING
72
89
  end
73
- else
74
- UI.message("no pending release version exist.")
90
+ rescue => error
91
+ UI.user_error!("The taiwan_number_one plugin action is finished with error: #{error.message}!")
92
+ return ActionResult::DO_NOTHING
75
93
  end
76
- UI.message("The taiwan_number_one plugin action is finished!")
77
94
  end
78
95
 
79
96
  def self.fetch_decision
@@ -94,26 +111,32 @@ module Fastlane
94
111
  def self.release_version_if_possible(app: nil, app_store_version: Spaceship::ConnectAPI::AppStoreVersion)
95
112
  unless app
96
113
  UI.user_error!("Could not find app with bundle identifier '#{params[:app_identifier]}' on account #{params[:username]}")
114
+ return ActionResult::DO_NOTHING
97
115
  end
98
116
 
99
117
  begin
100
118
  app_store_version.create_app_store_version_release_request
101
119
  UI.message("release version #{app_store_version.version_string} successfully!")
120
+ return ActionResult::SUCCESS
102
121
  rescue => e
103
122
  UI.user_error!("An error occurred while releasing version #{app_store_version}")
104
123
  UI.error("#{e.message}\n#{e.backtrace.join("\n")}") if FastlaneCore::Globals.verbose?
124
+ return ActionResult::DO_NOTHING
105
125
  end
106
126
  end
107
127
 
108
128
  def self.reject_version_if_possible(app: nil, app_store_version: Spaceship::ConnectAPI::AppStoreVersion)
109
129
  unless app
110
130
  UI.user_error!("Could not find app with bundle identifier '#{params[:app_identifier]}' on account #{params[:username]}")
131
+ return ActionResult::DO_NOTHING
111
132
  end
112
133
 
113
134
  if app_store_version.reject!
114
135
  UI.success("rejected version #{app_store_version.version_string} Successfully!")
136
+ return ActionResult::SUCCESS
115
137
  else
116
138
  UI.user_error!("An error occurred while rejected version #{app_store_version}")
139
+ return ActionResult::DO_NOTHING
117
140
  end
118
141
  end
119
142
 
@@ -133,7 +156,7 @@ module Fastlane
133
156
  end
134
157
 
135
158
  def self.return_value
136
- # If your method provides a return value, you can describe here what it does
159
+ return "'Success' if action passes, else, 'Nothing has changed'"
137
160
  end
138
161
 
139
162
  def self.details
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module TaiwanNumberOne
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-taiwan_number_one
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - andrew54068