fastlane-plugin-react_native_release 0.3.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +120 -41
  3. data/lib/fastlane/plugin/react_native_release/actions/accept_android_sdk_licenses.rb +46 -0
  4. data/lib/fastlane/plugin/react_native_release/actions/add_app_var.rb +107 -0
  5. data/lib/fastlane/plugin/react_native_release/actions/add_fastlane_var.rb +99 -0
  6. data/lib/fastlane/plugin/react_native_release/actions/create_changelog.rb +92 -0
  7. data/lib/fastlane/plugin/react_native_release/actions/create_fastlane_session.rb +75 -0
  8. data/lib/fastlane/plugin/react_native_release/actions/decrypt_android_keystore.rb +131 -0
  9. data/lib/fastlane/plugin/react_native_release/actions/decrypt_app_vars.rb +117 -0
  10. data/lib/fastlane/plugin/react_native_release/actions/decrypt_fastlane_vars.rb +101 -0
  11. data/lib/fastlane/plugin/react_native_release/actions/decrypt_google_play_credentials.rb +62 -0
  12. data/lib/fastlane/plugin/react_native_release/actions/determine_release_from_commits.rb +61 -0
  13. data/lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb +121 -0
  14. data/lib/fastlane/plugin/react_native_release/actions/encrypt_fastlane_vars.rb +76 -0
  15. data/lib/fastlane/plugin/react_native_release/actions/encrypt_google_play_credentials.rb +64 -0
  16. data/lib/fastlane/plugin/react_native_release/actions/generate_android_keystore.rb +137 -0
  17. data/lib/fastlane/plugin/react_native_release/actions/{react_native_release_action.rb → react_native_release.rb} +35 -66
  18. data/lib/fastlane/plugin/react_native_release/actions/read_fastlane_session.rb +55 -0
  19. data/lib/fastlane/plugin/react_native_release/actions/tag_release.rb +65 -0
  20. data/lib/fastlane/plugin/react_native_release/helper/react_native_release_helper.rb +14 -5
  21. data/lib/fastlane/plugin/react_native_release/version.rb +1 -1
  22. metadata +20 -5
@@ -4,47 +4,39 @@ require_relative '../helper/react_native_release_helper'
4
4
  module Fastlane
5
5
  module Actions
6
6
  class ReactNativeReleaseAction < Action
7
- VALID_TARGETS = %w{beta production}
7
+ VALID_RELEASE_TYPES = %w{beta release hotfix}
8
8
 
9
+ # params:
10
+ # release_type, alpha_branch, beta_branch, release_branch, hotfix_destination
9
11
  def self.run(params)
10
12
  require 'fastlane/plugin/android_versioning'
11
-
12
- if UI.select("Generate a fastlane session token? (The session token is used to authenticate with the App Store to upload iOS releases.)", ["yes", "no"]) === 'yes'
13
- create_fastlane_session
14
- end
13
+ other_action.create_fastlane_session
14
+
15
+ release_type = params[:release_type] || UI.select("Select a release type:", VALID_RELEASE_TYPES)
16
+ is_beta = release_type.include?('beta')
17
+ is_release = release_type.include?('release')
18
+ is_hotfix = release_type.include?('hotfix')
15
19
 
16
- target = UI.select "Select a release type:", VALID_TARGETS
17
- is_beta = target.include?('beta')
18
- is_hotfix = params[:hotfix] === true
19
20
  ios_version = other_action.get_version_number(xcodeproj: params[:xcodeproj], target: File.basename(params[:xcodeproj], '.*'))
20
21
  android_version = other_action.get_version_name(app_project_dir: params[:android_app_dir])
21
22
  should_prompt_for_version_bump = params[:prompt_for_version_bump] === true || is_beta
22
23
 
23
24
  if is_beta
24
- tag_prefix = 'betas'
25
- base_branch = params[:alpha_branch]
26
- target_branch = params[:beta_branch]
27
- else
28
- tag_prefix = 'releases'
29
- base_branch = params[:beta_branch]
30
- target_branch = params[:production_branch]
25
+ # TODO: ohter branches
26
+ verify_git_branch_state(beta_branch)
31
27
  end
32
28
 
33
- # Ensure we're on the right branch and in a good state
34
- other_action.ensure_git_branch(branch: base_branch)
35
- other_action.ensure_git_status_clean
36
- sh "git branch --set-upstream-to=origin/#{base_branch} #{base_branch}"
37
- other_action.git_pull
29
+ # TODO: flows
38
30
 
39
31
  # Cut a fresh branch unless this is a hotfix
40
- if !is_hotfix
41
- # delete an existing branch if we have one
42
- sh "git show-ref #{target_branch}" do |status|
43
- sh "git branch -D #{target_branch}" if status.success?
44
- end
32
+ # if !is_hotfix
33
+ # # delete an existing branch if we have one
34
+ # sh "git show-ref #{target_branch}" do |status|
35
+ # sh "git branch -D #{target_branch}" if status.success?
36
+ # end
45
37
 
46
- sh "git checkout -b #{target_branch}"
47
- end
38
+ # sh "git checkout -b #{target_branch}"
39
+ # end
48
40
 
49
41
  # Tag / Bump version
50
42
  if should_prompt_for_version_bump
@@ -63,13 +55,13 @@ module Fastlane
63
55
  end
64
56
  end
65
57
 
66
- # Tag it
67
- tag_name = "#{tag_prefix}/ios-#{ios_version}-android-#{android_version}"
58
+ # Tag it. TODO: release
59
+ tag_name = "release/ios-#{ios_version}-android-#{android_version}"
68
60
  other_action.add_git_tag(tag: tag_name)
69
- other_action.push_to_git_remote(
70
- local_branch: target_branch,
71
- force: true
72
- )
61
+ # other_action.push_to_git_remote(
62
+ # local_branch: target_branch,
63
+ # force: true
64
+ # )
73
65
 
74
66
  merge_branch(branch: target_branch, target: base_branch)
75
67
  return if is_beta
@@ -85,7 +77,7 @@ module Fastlane
85
77
  target = options[:target]
86
78
 
87
79
  sh "git checkout #{target}"
88
- sh "git merge origin/#{branch} --no-ff -m 'Merge #{branch} -> #{target} [skip ci]' " do |status|
80
+ sh "git merge origin/#{branch} --no-ff -m 'chore(release): Merge #{branch} -> #{target} [skip ci]' " do |status|
89
81
  unless status.success?
90
82
  UI.error "Failed to merge #{branch} into #{target}"
91
83
  end
@@ -118,49 +110,26 @@ module Fastlane
118
110
  bump_type: version_bump
119
111
  )
120
112
  end
113
+
114
+ def self.verify_git_branch_state(branch)
115
+ # Ensure we're on the right branch and in a good state
116
+ # other_action.ensure_git_branch(branch)
117
+ other_action.ensure_git_status_clean
118
+ sh "git branch --set-upstream-to=origin/#{branch} #{branch}"
119
+ other_action.git_pull
120
+ end
121
121
 
122
122
  def self.prompt_for_version
123
123
  UI.select("Update Version?: ", ["none", "major", "minor", "patch"])
124
124
  end
125
125
 
126
- #
127
- def self.create_fastlane_session()
128
- require 'fastlane/plugin/cryptex'
129
-
130
- UI.message "Generating a new FASTLANE_SESSION."
131
-
132
- file = Tempfile.new('')
133
-
134
- fastlane_session_git_url = ENV["FASTLANE_ENV_GIT_URL"]
135
- fastlane_session_username = ENV["FASTLANE_ENV_USERNAME"]
136
-
137
- if !fastlane_session_username;
138
- UI.user_error!("No FASTLANE_ENV_USERNAME var at <root>/fastlane/.env\nFASTLANE_ENV_USERNAME is used to authenticate with the App Store for iOS releases.")
139
- elsif !fastlane_session_git_url;
140
- UI.user_error!("No FASTLANE_ENV_GIT_URL var at <root>/fastlane/.env\nFASTLANE_ENV_GIT_URL is used to store the App Store Connect session to upload releases on CI.")
141
- else
142
- system "yes | fastlane spaceauth -u #{fastlane_session_username}"
143
- system "pbpaste > #{file.path}"
144
-
145
- UI.message "File created at: #{file.path}"
146
-
147
- other_action.cryptex(
148
- type: "import",
149
- in: file.path,
150
- key: "FASTLANE_SESSION",
151
- git_url: fastlane_session_git_url
152
- )
153
-
154
- UI.message "Uploaded FASTLANE_SESSION securely to git repository."
155
- end
156
- end
157
126
 
158
127
  def self.description
159
128
  "Simplify releases for React Native apps"
160
129
  end
161
130
 
162
131
  def self.authors
163
- ["cball"]
132
+ ["cball", "isaiahgrey93"]
164
133
  end
165
134
 
166
135
  def self.return_value
@@ -0,0 +1,55 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane/plugin/cryptex'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class ReadFastlaneSessionAction < Action
7
+ def self.run(params)
8
+ key = Helper::ReactNativeReleaseHelper::FASTLANE_SESSION_CRYPTEX_KEY
9
+ fastlane_session_git_url = ENV["CRYPTEX_GIT_URL"]
10
+ fastlane_session_password = ENV["CRYPTEX_PASSWORD"]
11
+ fastlane_session_cookie_path = Tempfile.new('')
12
+
13
+ UI.message "Reading fastlane session.."
14
+
15
+ other_action.cryptex(
16
+ type: "export",
17
+ out: fastlane_session_cookie_path.path,
18
+ key: key,
19
+ )
20
+
21
+ fastlane_session = (open fastlane_session_cookie_path.path).read
22
+
23
+ UI.message fastlane_session_cookie_path.path
24
+ UI.message fastlane_session
25
+
26
+ ENV["FASTLANE_SESSION"] = fastlane_session
27
+
28
+ UI.success "Read FASTLANE_SESSION from remote repository."
29
+ end
30
+
31
+ def self.description
32
+ "Simplify 2FA authentication for App Store Connect"
33
+ end
34
+
35
+ def self.authors
36
+ ["cball", "isaiahgrey93"]
37
+ end
38
+
39
+ def self.return_value
40
+ # If your method provides a return value, you can describe here what it does
41
+ end
42
+
43
+ def self.details
44
+ "Fetches an encrypted cookie for authenticating with App Store connecting. Handles fetching and decrypting the cookie before setting to the local env."
45
+ end
46
+
47
+ def self.is_supported?(platform)
48
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
49
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
50
+ #
51
+ [:ios, :android].include?(platform)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,65 @@
1
+ require 'fastlane/action'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class TagReleaseAction < Action
6
+ def self.run(params)
7
+ tag_prefix = params[:tag_prefix]
8
+ next_version = params[:next_version]
9
+ build_number = params[:build_number]
10
+
11
+ # Create tag to represent the new version
12
+ # TODO handle the case of not having proper git permissions
13
+ other_action.add_git_tag(tag: "#{tag_prefix}/#{next_version}/#{build_number}")
14
+ other_action.push_git_tags
15
+ other_action.push_to_git_remote
16
+ end
17
+
18
+ #####################################################
19
+ # @!group documentation
20
+ #####################################################
21
+
22
+ def self.description
23
+ "Tags a release based on a prefix, version, and build numbers"
24
+ end
25
+
26
+ def self.details
27
+ # TODO
28
+ end
29
+
30
+ def self.available_options
31
+ [
32
+ FastlaneCore::ConfigItem.new(key: :tag_prefix,
33
+ env_name: "FL_TAG_RELEASE_TAG_PREFIX",
34
+ description: "The prefix for tags (ex. ios/beta, android/beta)",
35
+ type: String),
36
+ FastlaneCore::ConfigItem.new(key: :next_version,
37
+ env_name: "FL_TAG_RELEASE_NEXT_VERSION",
38
+ description: "The next version to release",
39
+ type: String),
40
+ FastlaneCore::ConfigItem.new(key: :build_number,
41
+ env_name: "FL_TAG_RELEASE_BUILD_NUMBER",
42
+ description: "The current build number from CI",
43
+ type: String)
44
+ ]
45
+ end
46
+
47
+ def self.return_value
48
+ # If your method provides a return value, you can describe here what it does
49
+ end
50
+
51
+ def self.details
52
+ # "Saves the current vars in android/fastlane/.env and ios/fastlane/.env"
53
+ end
54
+
55
+ def self.authors
56
+ # So no one will ever forget your contribution to fastlane :) You are awesome btw!
57
+ ["cball"]
58
+ end
59
+
60
+ def self.is_supported?(platform)
61
+ [:ios, :android].include?(platform)
62
+ end
63
+ end
64
+ end
65
+ end
@@ -5,11 +5,20 @@ module Fastlane
5
5
 
6
6
  module Helper
7
7
  class ReactNativeReleaseHelper
8
- # class methods that you define here become available in your action
9
- # as `Helper::ReactNativeReleaseHelper.your_method`
10
- #
11
- def self.show_message
12
- UI.message("Hello from the react_native_release plugin helper!")
8
+ FASTLANE_CRYPTEX_KEY = 'fastlane_vars'
9
+ APP_CRYPTEX_KEY = 'app_vars'
10
+ APP_ENV_PATH = '.env'
11
+ VALID_NAMESPACES = ['alpha', 'beta', 'release', ''] # empty string denotes root namespace
12
+ ANDROID_KEYSTORE_CRYPTEX_KEY = 'ANDROID_KEYSTORE'
13
+ ANDROID_KEYSTORE_PATH = "../app/android.keystore"
14
+ GOOGLE_PLAY_CREDENTIALS_CRYPTEX_KEY = 'GOOGLE_PLAY_CREDS'
15
+ FASTLANE_SESSION_CRYPTEX_KEY = 'FASTLANE_SESSION'
16
+
17
+ # returns an app key for a specific namespace. Ex: beta_app_vars
18
+ def self.app_key_for(namespace)
19
+ return APP_CRYPTEX_KEY if namespace.strip.empty?
20
+
21
+ "#{namespace}_#{APP_CRYPTEX_KEY}"
13
22
  end
14
23
  end
15
24
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module ReactNativeRelease
3
- VERSION = "0.3.0"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-react_native_release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Ball
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-13 00:00:00.000000000 Z
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastlane-plugin-android_versioning
@@ -173,7 +173,23 @@ files:
173
173
  - LICENSE
174
174
  - README.md
175
175
  - lib/fastlane/plugin/react_native_release.rb
176
- - lib/fastlane/plugin/react_native_release/actions/react_native_release_action.rb
176
+ - lib/fastlane/plugin/react_native_release/actions/accept_android_sdk_licenses.rb
177
+ - lib/fastlane/plugin/react_native_release/actions/add_app_var.rb
178
+ - lib/fastlane/plugin/react_native_release/actions/add_fastlane_var.rb
179
+ - lib/fastlane/plugin/react_native_release/actions/create_changelog.rb
180
+ - lib/fastlane/plugin/react_native_release/actions/create_fastlane_session.rb
181
+ - lib/fastlane/plugin/react_native_release/actions/decrypt_android_keystore.rb
182
+ - lib/fastlane/plugin/react_native_release/actions/decrypt_app_vars.rb
183
+ - lib/fastlane/plugin/react_native_release/actions/decrypt_fastlane_vars.rb
184
+ - lib/fastlane/plugin/react_native_release/actions/decrypt_google_play_credentials.rb
185
+ - lib/fastlane/plugin/react_native_release/actions/determine_release_from_commits.rb
186
+ - lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb
187
+ - lib/fastlane/plugin/react_native_release/actions/encrypt_fastlane_vars.rb
188
+ - lib/fastlane/plugin/react_native_release/actions/encrypt_google_play_credentials.rb
189
+ - lib/fastlane/plugin/react_native_release/actions/generate_android_keystore.rb
190
+ - lib/fastlane/plugin/react_native_release/actions/react_native_release.rb
191
+ - lib/fastlane/plugin/react_native_release/actions/read_fastlane_session.rb
192
+ - lib/fastlane/plugin/react_native_release/actions/tag_release.rb
177
193
  - lib/fastlane/plugin/react_native_release/helper/react_native_release_helper.rb
178
194
  - lib/fastlane/plugin/react_native_release/version.rb
179
195
  homepage: https://github.com/echobind/fastlane-plugin-react_native_release
@@ -195,8 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
211
  - !ruby/object:Gem::Version
196
212
  version: '0'
197
213
  requirements: []
198
- rubyforge_project:
199
- rubygems_version: 2.7.9
214
+ rubygems_version: 3.0.6
200
215
  signing_key:
201
216
  specification_version: 4
202
217
  summary: Simplify releases for React Native apps.