fastlane-plugin-react_native_release 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +118 -45
  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 +109 -0
  5. data/lib/fastlane/plugin/react_native_release/actions/create_fastlane_session.rb +75 -0
  6. data/lib/fastlane/plugin/react_native_release/actions/decrypt_android_keystore.rb +131 -0
  7. data/lib/fastlane/plugin/react_native_release/actions/decrypt_app_vars.rb +106 -0
  8. data/lib/fastlane/plugin/react_native_release/actions/decrypt_fastlane_vars.rb +64 -0
  9. data/lib/fastlane/plugin/react_native_release/actions/decrypt_google_play_credentials.rb +62 -0
  10. data/lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb +110 -0
  11. data/lib/fastlane/plugin/react_native_release/actions/encrypt_fastlane_vars.rb +61 -0
  12. data/lib/fastlane/plugin/react_native_release/actions/encrypt_google_play_credentials.rb +64 -0
  13. data/lib/fastlane/plugin/react_native_release/actions/generate_android_keystore.rb +137 -0
  14. data/lib/fastlane/plugin/react_native_release/actions/{react_native_release_action.rb → react_native_release.rb} +33 -31
  15. data/lib/fastlane/plugin/react_native_release/actions/read_fastlane_session.rb +55 -0
  16. data/lib/fastlane/plugin/react_native_release/helper/react_native_release_helper.rb +14 -5
  17. data/lib/fastlane/plugin/react_native_release/version.rb +1 -1
  18. metadata +16 -6
  19. data/lib/fastlane/plugin/react_native_release/actions/create_fastlane_session_action.rb +0 -63
  20. data/lib/fastlane/plugin/react_native_release/actions/read_fastlane_session_action.rb +0 -67
@@ -0,0 +1,131 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane/plugin/cryptex'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class DecryptAndroidKeystoreAction < Action
7
+ def self.run(params)
8
+ key = Helper::ReactNativeReleaseHelper::ANDROID_KEYSTORE_CRYPTEX_KEY
9
+ file = Helper::ReactNativeReleaseHelper::ANDROID_KEYSTORE_PATH
10
+
11
+ begin
12
+ env_file_exists = File.exists?(file)
13
+
14
+ if (env_file_exists && UI.confirm("This will overwrite your existing .env file. Proceed?"))
15
+ self.export_and_decrypt_keystore(file,key)
16
+
17
+ elsif(env_file_exists)
18
+ UI.abort_with_message!("Stepping away...")
19
+ else
20
+ self.export_and_decrypt_keystore(file,key)
21
+ end
22
+ # If we don't have a keystore, cryptex will throw an exception.
23
+ rescue => ex
24
+ UI.abort_with_message!('Error decrypting keystore. Does it exist in the repo?')
25
+ end
26
+
27
+ UI.success("Decrypted #{key} to keystore.")
28
+ end
29
+
30
+ def self.export_and_decrypt_keystore(file,key)
31
+ other_action.cryptex(
32
+ type: "export",
33
+ out: file,
34
+ key: key,
35
+ verbose: true
36
+ )
37
+ # There is currently a bug where the keystore needs to be in multiple paths
38
+ # Optimized for the CI process to be running from the lane in android directory
39
+ sh("cp ./app/android.keystore ./")
40
+ end
41
+
42
+ # Creates a new android keystore based on the provided params. Wraps Cryptex.
43
+ def self.create_keystore_with_params(params)
44
+ begin
45
+ other_action.cryptex_generate_keystore(
46
+ destination: params[:destination],
47
+ password: params[:password],
48
+ fullname: params[:fullname],
49
+ city: params[:city],
50
+ alias: params[:alias]
51
+ )
52
+ rescue => ex
53
+ UI.abort_with_message!("Could not create keystore. Do you already have one with this alias?")
54
+ end
55
+
56
+ params[:destination]
57
+ end
58
+
59
+ # Saves a keystore to the repo. Note this will overwrite it!
60
+ def self.encrypt_keystore(keystore_path)
61
+ key = Helper::ReactNativeReleaseHelper::ANDROID_KEYSTORE_CRYPTEX_KEY
62
+
63
+ other_action.cryptex(
64
+ type: "import",
65
+ in: keystore_path,
66
+ key: key
67
+ )
68
+ end
69
+
70
+ #####################################################
71
+ # @!group Documentation
72
+ #####################################################
73
+
74
+ def self.description
75
+ "Decrypts app env vars and sets the values in the root .env file"
76
+ end
77
+
78
+ def self.details
79
+ # Optional:
80
+ # this is your chance to provide a more detailed description of this action
81
+ end
82
+
83
+ def self.available_options
84
+ [
85
+ FastlaneCore::ConfigItem.new(key: :encrypt_in_repo,
86
+ env_name: "FL_GENERATE_ANDROID_KEYSTORE_ENCRYPT_IN_REPO",
87
+ description: "If the new keystore should be encrypted and saved",
88
+ type: Boolean,
89
+ default_value: false),
90
+ FastlaneCore::ConfigItem.new(key: :password,
91
+ env_name: "FL_GENERATE_ANDROID_KEYSTORE_PASSWORD",
92
+ description: "Password for the Keystore",
93
+ type: String),
94
+ FastlaneCore::ConfigItem.new(key: :alias,
95
+ env_name: "FL_GENERATE_ANDROID_KEYSTORE_ALIAS",
96
+ description: "ALIAS for the Keystore",
97
+ type: String),
98
+ FastlaneCore::ConfigItem.new(key: :destination,
99
+ env_name: "FL_GENERATE_ANDROID_KEYSTORE_DESTINATION",
100
+ description: "Where to put decrypted keystore",
101
+ default_value: "../android/app/android.keystore"),
102
+ FastlaneCore::ConfigItem.new(key: :fullname,
103
+ env_name: "FL_GENERATE_ANDROID_KEYSTORE_FULLNAME",
104
+ description: "Fullname of keystore owner",
105
+ type: String),
106
+ FastlaneCore::ConfigItem.new(key: :city,
107
+ env_name: "FL_GENERATE_ANDROID_KEYSTORE_CITY",
108
+ description: "City of keystore owner",
109
+ type: String),
110
+ ]
111
+ end
112
+
113
+ def self.return_value
114
+ # If your method provides a return value, you can describe here what it does
115
+ end
116
+
117
+ def self.details
118
+ # "Saves the current vars in android/fastlane/.env and ios/fastlane/.env"
119
+ end
120
+
121
+ def self.authors
122
+ # So no one will ever forget your contribution to fastlane :) You are awesome btw!
123
+ ["cball", "isaiahgrey93", "cmejet"]
124
+ end
125
+
126
+ def self.is_supported?(platform)
127
+ [:ios, :android].include?(platform)
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,106 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane/plugin/cryptex'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class DecryptAppVarsAction < Action
7
+ def self.run(params)
8
+ is_ci = ENV['CI'] === 'true'
9
+ namespace = params[:namespace]
10
+ write_env = params[:write_env]
11
+ default_cryptex_app_key = Helper::ReactNativeReleaseHelper::APP_CRYPTEX_KEY
12
+ cryptex_app_key = Helper::ReactNativeReleaseHelper.app_key_for(namespace)
13
+ is_same_key = default_cryptex_app_key == cryptex_app_key
14
+ message = ''
15
+
16
+ if is_same_key
17
+ message = "This will decrypt values from #{cryptex_app_key}. Proceed?"
18
+ else
19
+ message = "This will decrypt and merge values from #{cryptex_app_key} into #{default_cryptex_app_key}. Proceed?"
20
+ end
21
+
22
+ if !is_ci && !UI.confirm(message)
23
+ UI.abort_with_message!("Stepping away...")
24
+ end
25
+
26
+ app_vars = other_action.cryptex(
27
+ type: "export_env",
28
+ key: default_cryptex_app_key
29
+ )
30
+
31
+ namespaced_vars = other_action.cryptex(
32
+ type: "export_env",
33
+ key: cryptex_app_key
34
+ )
35
+
36
+ merged_vars = app_vars.merge(namespaced_vars)
37
+ has_env_file = File.exists?(Helper::ReactNativeReleaseHelper::APP_ENV_PATH)
38
+ should_write_env = write_env && (is_ci || !has_env_file || UI.confirm("It looks like you already have an .env file. Overwrite it?"))
39
+
40
+ # write an env file with the merged values
41
+ if (should_write_env)
42
+ # TODO: handle running action from root and from ios/android folders. This will not work properly in the root as is.
43
+ open('../.env', 'w') do |f|
44
+ merged_vars.each {|key, value| f.puts "#{key}=#{value}" }
45
+ end
46
+
47
+ UI.success('.env written')
48
+ else
49
+ UI.success('not writing .env')
50
+ end
51
+
52
+ merged_vars
53
+ end
54
+
55
+ #####################################################
56
+ # @!group Documentation
57
+ #####################################################
58
+
59
+ def self.description
60
+ "Decrypts app env vars and sets the values in the root .env file"
61
+ end
62
+
63
+ def self.details
64
+ # Optional:
65
+ # this is your chance to provide a more detailed description of this action
66
+ end
67
+
68
+ def self.available_options
69
+ [
70
+ FastlaneCore::ConfigItem.new(key: :namespace,
71
+ env_name: "FL_DECRYPT_APP_VARS_NAMESPACE", # The name of the environment variable
72
+ description: "What namespace should we use? (alpha, beta, release, ENTER = root)", # a short description of this parameter
73
+ type: String,
74
+ verify_block: lambda do |value|
75
+ unless Helper::ReactNativeReleaseHelper::VALID_NAMESPACES.include?(value)
76
+ UI.user_error!("Invalid namespace #{value}. Valid targets are #{Helper::ReactNativeReleaseHelper::VALID_NAMESPACES.join(', ')}")
77
+ next
78
+ end
79
+ end),
80
+ FastlaneCore::ConfigItem.new(key: :write_env,
81
+ env_name: "FL_DECRYPT_APP_VARS_WRITE_ENV", # The name of the environment variable
82
+ description: "If we should write an .env file", # a short description of this parameter
83
+ type: Boolean,
84
+ default_value: true)
85
+ ]
86
+ end
87
+
88
+ def self.return_value
89
+ # If your method provides a return value, you can describe here what it does
90
+ end
91
+
92
+ def self.details
93
+ # "Saves the current vars in android/fastlane/.env and ios/fastlane/.env"
94
+ end
95
+
96
+ def self.authors
97
+ # So no one will ever forget your contribution to fastlane :) You are awesome btw!
98
+ ["cball", "isaiahgrey93"]
99
+ end
100
+
101
+ def self.is_supported?(platform)
102
+ [:ios, :android].include?(platform)
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,64 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane/plugin/cryptex'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class DecryptFastlaneVarsAction < Action
7
+ def self.run(params)
8
+
9
+ env = other_action.cryptex(
10
+ type: "export_env",
11
+ key: Helper::ReactNativeReleaseHelper::FASTLANE_CRYPTEX_KEY,
12
+ set_env: params[:set_env]
13
+ )
14
+
15
+ UI.success('Decrypted fastlane vars')
16
+
17
+ env
18
+ end
19
+
20
+ #####################################################
21
+ # @!group Documentation
22
+ #####################################################
23
+
24
+ def self.description
25
+ "Decrypts fastlane ENV vars from the encrypted repo. Optionally sets them in ENV."
26
+ end
27
+
28
+ def self.details
29
+ # Optional:
30
+ # this is your chance to provide a more detailed description of this action
31
+ end
32
+
33
+ def self.available_options
34
+ # Define all options your action supports.
35
+
36
+ # Below a few examples
37
+ [
38
+ FastlaneCore::ConfigItem.new(key: :set_env,
39
+ env_name: "FL_DECRYPT_FASTLANE_VARS_SET_ENV", # The name of the environment variable
40
+ description: "Sets the decrypted values in env", # a short description of this parameter
41
+ type: Boolean,
42
+ default_value: true)
43
+ ]
44
+ end
45
+
46
+ def self.return_value
47
+ # If your method provides a return value, you can describe here what it does
48
+ end
49
+
50
+ def self.details
51
+ # "Saves the current vars in android/fastlane/.env and ios/fastlane/.env"
52
+ end
53
+
54
+ def self.authors
55
+ # So no one will ever forget your contribution to fastlane :) You are awesome btw!
56
+ ["cball", "isaiahgrey93"]
57
+ end
58
+
59
+ def self.is_supported?(platform)
60
+ [:ios, :android].include?(platform)
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,62 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane/plugin/cryptex'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class DecryptGooglePlayCredentialsAction < Action
7
+ def self.run(params)
8
+ key = Helper::ReactNativeReleaseHelper::GOOGLE_PLAY_CREDENTIALS_CRYPTEX_KEY
9
+ file = Tempfile.new('')
10
+
11
+ begin
12
+ other_action.cryptex(
13
+ type: "export",
14
+ key: key,
15
+ out: file.path
16
+ )
17
+ rescue => ex
18
+ UI.abort_with_message!('Error decrypting Google Play Credentials. Did you add them to the repo?')
19
+ end
20
+
21
+ google_creds = (open file.path).read
22
+ UI.success("Decrypted #{key}")
23
+
24
+ google_creds
25
+ end
26
+
27
+ #####################################################
28
+ # @!group Documentation
29
+ #####################################################
30
+
31
+ def self.description
32
+ "Decrypts app env vars and sets the values in the root .env file"
33
+ end
34
+
35
+ def self.details
36
+ # Optional:
37
+ # this is your chance to provide a more detailed description of this action
38
+ end
39
+
40
+ def self.available_options
41
+ []
42
+ end
43
+
44
+ def self.return_value
45
+ # If your method provides a return value, you can describe here what it does
46
+ end
47
+
48
+ def self.details
49
+ # "Saves the current vars in android/fastlane/.env and ios/fastlane/.env"
50
+ end
51
+
52
+ def self.authors
53
+ # So no one will ever forget your contribution to fastlane :) You are awesome btw!
54
+ ["cball", "isaiahgrey93"]
55
+ end
56
+
57
+ def self.is_supported?(platform)
58
+ [:ios, :android].include?(platform)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,110 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane/plugin/cryptex'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class EncryptAppVarsAction < Action
7
+ def self.run(params)
8
+ namespace = params[:namespace]
9
+ cryptex_app_key = app_key_for(namespace)
10
+ env_path = params[:env_path] || env_path_for(namespace)
11
+
12
+ if !File.exists?(env_path)
13
+ UI.user_error!("#{env_path} not found!")
14
+ end
15
+
16
+ if !UI.confirm("This will save values from #{env_path} to the #{cryptex_app_key} namespace in the encrypted context repo. Proceed?")
17
+ UI.abort_with_message!("Stepping away...")
18
+ end
19
+
20
+ app_vars = Dotenv.parse(env_path)
21
+ existing_app_vars = {}
22
+
23
+ begin
24
+ existing_app_vars = other_action.cryptex(
25
+ type: 'export_env',
26
+ key: cryptex_app_key,
27
+ )
28
+ rescue => ex
29
+ # If key doesn't exist cryptex will error
30
+ end
31
+
32
+ other_action.cryptex(
33
+ type: "import_env",
34
+ key: cryptex_app_key,
35
+ hash: existing_app_vars.merge(app_vars)
36
+ )
37
+
38
+ UI.success('Encrypted app ENV vars')
39
+ end
40
+
41
+ #####################################################
42
+ # @!group Documentation
43
+ #####################################################
44
+
45
+ def self.description
46
+ "Encrypts app env vars and stores them in the context repo."
47
+ end
48
+
49
+ def self.details
50
+ # Optional:
51
+ # this is your chance to provide a more detailed description of this action
52
+ end
53
+
54
+ def self.available_options
55
+ [
56
+ FastlaneCore::ConfigItem.new(key: :namespace,
57
+ env_name: "FL_ENCRYPT_APP_VARS_NAMESPACE", # The name of the environment variable
58
+ description: "What namespace should we use? (alpha, beta, release, ENTER = root)", # a short description of this parameter
59
+ type: String,
60
+ verify_block: lambda do |value|
61
+ unless Helper::ReactNativeReleaseHelper::VALID_NAMESPACES.include?(value)
62
+ UI.user_error!("Invalid namespace #{value}. Valid targets are #{Helper::ReactNativeReleaseHelper::VALID_NAMESPACES.join(', ')}")
63
+ next
64
+ end
65
+ end),
66
+ FastlaneCore::ConfigItem.new(key: :env_path,
67
+ env_name: "FL_ENCRYPT_APP_VARS_ENV_PATH", # The name of the environment variable
68
+ description: "A path to an ENV file that contains app related ENV vars", # a short description of this parameter
69
+ type: String,
70
+ optional: true)
71
+ ]
72
+ end
73
+
74
+ def self.return_value
75
+ # If your method provides a return value, you can describe here what it does
76
+ end
77
+
78
+ def self.details
79
+ # "Saves the current vars in android/fastlane/.env and ios/fastlane/.env"
80
+ end
81
+
82
+ def self.authors
83
+ # So no one will ever forget your contribution to fastlane :) You are awesome btw!
84
+ ["cball", "isaiahgrey93", "cmejet"]
85
+ end
86
+
87
+ def self.is_supported?(platform)
88
+ [:ios, :android].include?(platform)
89
+ end
90
+
91
+ # Returns a path for an env var. optionally namespaced
92
+ def self.env_path_for(namespace)
93
+ return default_env_path if namespace.strip.empty?
94
+ "#{default_env_path}.#{namespace}"
95
+ end
96
+
97
+ # Returns the app key for cryptex. optionally namespaced
98
+ def self.app_key_for(namespace)
99
+ default_app_key = Helper::ReactNativeReleaseHelper::APP_CRYPTEX_KEY
100
+ return default_app_key if namespace.strip.empty?
101
+
102
+ "#{namespace}_#{default_app_key}"
103
+ end
104
+
105
+ def self.default_env_path
106
+ Helper::ReactNativeReleaseHelper::APP_ENV_PATH
107
+ end
108
+ end
109
+ end
110
+ end