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
@@ -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,61 @@
1
+ require 'fastlane/action'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class DetermineReleaseFromCommitsAction < Action
6
+ VALID_PLATFORMS = %w{ios android}
7
+
8
+ def self.run(params)
9
+ ignore_scopes = params[:commit_ignore_scopes]
10
+ tag_prefix = params[:tag_prefix]
11
+ is_releaseable = analyze_commits(match: "#{tag_prefix}*", ignore_scopes: ignore_scopes)
12
+ next_version = lane_context[SharedValues::RELEASE_NEXT_VERSION]
13
+ # next unless is_releaseable
14
+
15
+ next_version
16
+ end
17
+
18
+ #####################################################
19
+ # @!group Documentation
20
+ #####################################################
21
+
22
+ def self.description
23
+ "Determines if a release should happen based on conventional commits."
24
+ end
25
+
26
+ def self.details
27
+ "If using conventional commits, only continues to release if there are features / fixes."
28
+ end
29
+
30
+ def self.available_options
31
+ [
32
+ FastlaneCore::ConfigItem.new(key: :commit_ignore_scopes,
33
+ env_name: "FL_DETERMINE_RELEASE_FROM_COMMITS_COMMIT_IGNORE_SCOPES",
34
+ description: "What scopes from commits should be ignored?",
35
+ type: String),
36
+ FastlaneCore::ConfigItem.new(key: :tag_prefix,
37
+ env_name: "FL_DETERMINE_RELEASE_FROM_COMMITS_TAG_PREFIX",
38
+ description: "The tag prefix to use (ex. ios/beta)",
39
+ type: String)
40
+ ]
41
+ end
42
+
43
+ def self.return_value
44
+ # If your method provides a return value, you can describe here what it does
45
+ end
46
+
47
+ def self.details
48
+ # "Saves the current vars in android/fastlane/.env and ios/fastlane/.env"
49
+ end
50
+
51
+ def self.authors
52
+ # So no one will ever forget your contribution to fastlane :) You are awesome btw!
53
+ ["cball"]
54
+ end
55
+
56
+ def self.is_supported?(platform)
57
+ [:ios, :android].include?(platform)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,121 @@
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
+ skip_confirmation= params[:skip_confirmation]
12
+
13
+
14
+ if !File.exists?(env_path)
15
+ UI.user_error!("#{env_path} not found!")
16
+ end
17
+
18
+ if(!skip_confirmation)
19
+ if !UI.confirm("This will save values from #{env_path} to the #{cryptex_app_key} namespace in the encrypted context repo. Proceed?")
20
+ UI.abort_with_message!("Stepping away...")
21
+ end
22
+ end
23
+
24
+ app_vars = Dotenv.parse(env_path)
25
+ existing_app_vars = {}
26
+
27
+ begin
28
+ existing_app_vars = other_action.cryptex(
29
+ type: 'export_env',
30
+ key: cryptex_app_key,
31
+ )
32
+ rescue => ex
33
+ # If key doesn't exist cryptex will error
34
+ end
35
+
36
+ other_action.cryptex(
37
+ type: "import_env",
38
+ key: cryptex_app_key,
39
+ hash: existing_app_vars.merge(app_vars)
40
+ )
41
+
42
+ UI.success('Encrypted app ENV vars')
43
+ end
44
+
45
+ #####################################################
46
+ # @!group Documentation
47
+ #####################################################
48
+
49
+ def self.description
50
+ "Encrypts app env vars and stores them in the context repo."
51
+ end
52
+
53
+ def self.details
54
+ # Optional:
55
+ # this is your chance to provide a more detailed description of this action
56
+ end
57
+
58
+ def self.available_options
59
+ [
60
+ FastlaneCore::ConfigItem.new(key: :namespace,
61
+ env_name: "FL_ENCRYPT_APP_VARS_NAMESPACE", # The name of the environment variable
62
+ description: "What namespace should we use? (alpha, beta, release, ENTER = root)", # a short description of this parameter
63
+ type: String,
64
+ verify_block: lambda do |value|
65
+ unless Helper::ReactNativeReleaseHelper::VALID_NAMESPACES.include?(value)
66
+ UI.user_error!("Invalid namespace #{value}. Valid targets are #{Helper::ReactNativeReleaseHelper::VALID_NAMESPACES.join(', ')}")
67
+ next
68
+ end
69
+ end),
70
+ FastlaneCore::ConfigItem.new(key: :env_path,
71
+ env_name: "FL_ENCRYPT_APP_VARS_ENV_PATH", # The name of the environment variable
72
+ description: "A path to an ENV file that contains app related ENV vars", # a short description of this parameter
73
+ type: String,
74
+ optional: true),
75
+ FastlaneCore::ConfigItem.new(key: :skip_confirmation,
76
+ env_name: "FL_ENCRYPT_APP_VARS_SKIP_CONFIRMATION", # The name of the environment variable
77
+ description: "Allows commands to be run from within CLI and skip the UI.message confirmation dialog", # a short description of this parameter
78
+ type: Boolean,
79
+ short_option:'s',
80
+ default_value: false,
81
+ optional: true),
82
+ ]
83
+ end
84
+
85
+ def self.return_value
86
+ # If your method provides a return value, you can describe here what it does
87
+ end
88
+
89
+ def self.details
90
+ # "Saves the current vars in android/fastlane/.env and ios/fastlane/.env"
91
+ end
92
+
93
+ def self.authors
94
+ # So no one will ever forget your contribution to fastlane :) You are awesome btw!
95
+ ["cball", "isaiahgrey93", "cmejet"]
96
+ end
97
+
98
+ def self.is_supported?(platform)
99
+ [:ios, :android].include?(platform)
100
+ end
101
+
102
+ # Returns a path for an env var. optionally namespaced
103
+ def self.env_path_for(namespace)
104
+ return default_env_path if namespace.strip.empty?
105
+ "#{default_env_path}.#{namespace}"
106
+ end
107
+
108
+ # Returns the app key for cryptex. optionally namespaced
109
+ def self.app_key_for(namespace)
110
+ default_app_key = Helper::ReactNativeReleaseHelper::APP_CRYPTEX_KEY
111
+ return default_app_key if namespace.strip.empty?
112
+
113
+ "#{namespace}_#{default_app_key}"
114
+ end
115
+
116
+ def self.default_env_path
117
+ Helper::ReactNativeReleaseHelper::APP_ENV_PATH
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,76 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane/plugin/cryptex'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class EncryptFastlaneVarsAction < Action
7
+ ANDROID_ENV_PATH = "./android/fastlane/.env"
8
+ IOS_ENV_PATH = './ios/fastlane/.env'
9
+ FASTLANE_CRYPTEX_KEY = 'fastlane_vars'
10
+
11
+ def self.run(params)
12
+ skip_confirmation= params[:skip_confirmation]
13
+
14
+ if !File.exists?(IOS_ENV_PATH)
15
+ UI.user_error!("No .env found in ios directory!")
16
+ end
17
+
18
+ if !File.exists?(ANDROID_ENV_PATH)
19
+ UI.user_error!("No .env found in Android directory")
20
+ end
21
+
22
+
23
+ if !skip_confirmation && !UI.confirm("This will save values from your #{IOS_ENV_PATH} and #{ANDROID_ENV_PATH} to the encrypted context repo. Proceed?")
24
+ UI.abort_with_message!("Stepping away...")
25
+ end
26
+
27
+ android_env_vars = Dotenv.parse(ANDROID_ENV_PATH)
28
+ ios_env_vars = Dotenv.parse(IOS_ENV_PATH)
29
+ vars = android_env_vars.merge(ios_env_vars)
30
+
31
+ other_action.cryptex(
32
+ type: "import_env",
33
+ key: FASTLANE_CRYPTEX_KEY,
34
+ hash: vars,
35
+ )
36
+
37
+ UI.success "ENV vars set in context repo."
38
+ end
39
+
40
+ def self.description
41
+ "Encrypt fastlane vars for CI"
42
+ end
43
+
44
+ def self.available_options
45
+ [
46
+ FastlaneCore::ConfigItem.new(key: :skip_confirmation,
47
+ env_name: "FL_ENCRYPT_APP_VARS_SKIP_CONFIRMATION", # The name of the environment variable
48
+ description: "Allows commands to be run from within CLI and skip the UI.message confirmation dialog", # a short description of this parameter
49
+ type: Boolean,
50
+ short_option:'s',
51
+ default_value: false,
52
+ optional: true),
53
+ ]
54
+ end
55
+
56
+ def self.authors
57
+ ["cball", "isaiahgrey93", "cmejet"]
58
+ end
59
+
60
+ def self.return_value
61
+ # If your method provides a return value, you can describe here what it does
62
+ end
63
+
64
+ def self.details
65
+ "Saves the current vars in android/fastlane/.env and ios/fastlane/.env"
66
+ end
67
+
68
+ def self.is_supported?(platform)
69
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
70
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
71
+ #
72
+ [:ios, :android].include?(platform)
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,64 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane/plugin/cryptex'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class EncryptGooglePlayCredentialsAction < Action
7
+ def self.run(params)
8
+ key = Helper::ReactNativeReleaseHelper::GOOGLE_PLAY_CREDENTIALS_CRYPTEX_KEY
9
+ json_path = params[:json_path]
10
+
11
+ begin
12
+ other_action.cryptex(
13
+ type: "import",
14
+ key: key,
15
+ in: json_path
16
+ )
17
+ rescue => ex
18
+ UI.abort_with_message!('Error encrypting Google Play Credentials.')
19
+ end
20
+
21
+ UI.success("Encrypted #{json_path} as #{key}")
22
+ end
23
+
24
+ #####################################################
25
+ # @!group Documentation
26
+ #####################################################
27
+
28
+ def self.description
29
+ "Encrypts credentials from Google Play and stores in the context repo."
30
+ end
31
+
32
+ def self.details
33
+ # Optional:
34
+ # this is your chance to provide a more detailed description of this action
35
+ end
36
+
37
+ def self.available_options
38
+ [
39
+ FastlaneCore::ConfigItem.new(key: :json_path,
40
+ env_name: "FL_ENCRYPT_GOOGLE_PLAY_CREDENTIALS_JSON_PATH",
41
+ description: "Enter path to the json you downloaded from Google, or drop the file here",
42
+ type: String)
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,137 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane/plugin/cryptex'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class GenerateAndroidKeystoreAction < Action
7
+ def self.run(params)
8
+ encrypt_in_repo = params[:encrypt_in_repo]
9
+ key = Helper::ReactNativeReleaseHelper::ANDROID_KEYSTORE_CRYPTEX_KEY
10
+
11
+ # Confirm if there is an existing key in the repo... we don't want to overwrite prod!
12
+ begin
13
+ existing_remote_key = other_action.cryptex(
14
+ type: "export",
15
+ key: key
16
+ )
17
+ # If we don't have a keystore, cryptex will throw an exception.
18
+ rescue => ex
19
+ # create a new keystore and encrypt it
20
+ UI.message('no keystore found in repo. creating it.')
21
+ keystore = create_keystore_with_params(params)
22
+ message = 'Created keystore'
23
+
24
+ if encrypt_in_repo
25
+ encrypt_keystore(keystore)
26
+ message.concat(' and saved to repo.')
27
+ end
28
+
29
+ UI.success(message)
30
+ end
31
+
32
+ # If encrypting, confirm remote overwrite
33
+ if (encrypt_in_repo && UI.confirm("This will overwrite your existing keystore! Are you sure?"))
34
+ keystore_path = create_keystore_with_params(params)
35
+ encrypt_keystore(keystore_path)
36
+ UI.success('Created keystore and saved to repo.')
37
+ elsif encrypt_in_repo
38
+ # The user does not want to proceed
39
+ UI.abort_with_message!("Stepping away...")
40
+ else
41
+ # Create, but don't encrypt
42
+ create_keystore_with_params(params)
43
+
44
+ UI.success('Created keystore, but did not save it to the repo.')
45
+ end
46
+ end
47
+
48
+ # Creates a new android keystore based on the provided params. Wraps Cryptex.
49
+ def self.create_keystore_with_params(params)
50
+ begin
51
+ other_action.cryptex_generate_keystore(
52
+ destination: params[:destination],
53
+ password: params[:password],
54
+ fullname: params[:fullname],
55
+ city: params[:city],
56
+ alias: params[:alias]
57
+ )
58
+ rescue => ex
59
+ UI.abort_with_message!("Could not create keystore. Do you already have one with this alias?")
60
+ end
61
+
62
+ params[:destination]
63
+ end
64
+
65
+ # Saves a keystore to the repo. Note this will overwrite it!
66
+ def self.encrypt_keystore(keystore_path)
67
+ key = Helper::ReactNativeReleaseHelper::ANDROID_KEYSTORE_CRYPTEX_KEY
68
+
69
+ other_action.cryptex(
70
+ type: "import",
71
+ in: keystore_path,
72
+ key: key
73
+ )
74
+ end
75
+
76
+ #####################################################
77
+ # @!group Documentation
78
+ #####################################################
79
+
80
+ def self.description
81
+ "Decrypts app env vars and sets the values in the root .env file"
82
+ end
83
+
84
+ def self.details
85
+ # Optional:
86
+ # this is your chance to provide a more detailed description of this action
87
+ end
88
+
89
+ def self.available_options
90
+ [
91
+ FastlaneCore::ConfigItem.new(key: :encrypt_in_repo,
92
+ env_name: "FL_GENERATE_ANDROID_KEYSTORE_ENCRYPT_IN_REPO",
93
+ description: "If the new keystore should be encrypted and saved",
94
+ type: Boolean,
95
+ default_value: false),
96
+ FastlaneCore::ConfigItem.new(key: :password,
97
+ env_name: "FL_GENERATE_ANDROID_KEYSTORE_PASSWORD",
98
+ description: "Password for the Keystore",
99
+ type: String),
100
+ FastlaneCore::ConfigItem.new(key: :alias,
101
+ env_name: "FL_GENERATE_ANDROID_KEYSTORE_ALIAS",
102
+ description: "ALIAS for the Keystore",
103
+ type: String),
104
+ FastlaneCore::ConfigItem.new(key: :destination,
105
+ env_name: "FL_GENERATE_ANDROID_KEYSTORE_DESTINATION",
106
+ description: "Where to put decrypted keystore",
107
+ default_value: Helper::ReactNativeReleaseHelper::ANDROID_KEYSTORE_PATH),
108
+ FastlaneCore::ConfigItem.new(key: :fullname,
109
+ env_name: "FL_GENERATE_ANDROID_KEYSTORE_FULLNAME",
110
+ description: "Fullname of keystore owner",
111
+ type: String),
112
+ FastlaneCore::ConfigItem.new(key: :city,
113
+ env_name: "FL_GENERATE_ANDROID_KEYSTORE_CITY",
114
+ description: "City of keystore owner",
115
+ type: String),
116
+ ]
117
+ end
118
+
119
+ def self.return_value
120
+ # If your method provides a return value, you can describe here what it does
121
+ end
122
+
123
+ def self.details
124
+ # "Saves the current vars in android/fastlane/.env and ios/fastlane/.env"
125
+ end
126
+
127
+ def self.authors
128
+ # So no one will ever forget your contribution to fastlane :) You are awesome btw!
129
+ ["cball", "isaiahgrey93"]
130
+ end
131
+
132
+ def self.is_supported?(platform)
133
+ [:ios, :android].include?(platform)
134
+ end
135
+ end
136
+ end
137
+ end