You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This new implementation fixes the following issues that we had in the old implementation:
- Issues and security risk with paths containing spaces or special parameters
- This would not only have made the command fail
- But it also created a security issue for parameter injection (e.g. `apk_output_file_path: 'foo --inject this && echo print the rest'`)
- Risk of deleting any arbitrary folder on disk (due to use of unchecked `rm -rf`)
- Calling the action with `apk_output_file_path: '.'` for example (or a path to any directory) would have the side effect of… deleting the whole content of the current directory before failing
- This was even more problematic that this could be an easy genuine accidental error to make—especially if the caller misread the documentation and thought that the command accepted a folder for the output path instead of the path to the apk file.
In addition, this commit adds the following features to the action's behavior:
- The action will detect if the parent directory of the `apk_output_file_path` does not exist, and exit early with a nice error if so
- We now allow `apk_output_file_path` to be a directory, and if so the output file will be put in that directory and use the same basename as the input aab_file_path (but with `.apk` extension instead of `.aab`)
- The action now returns the path to the generated file (which is especially useful if you didn't provide an explicit value for `apk_output_file_path` and let the action infer it, or if you provided a directory for this output path)
UI.user_error!('bundletool is not installed. Please install it using the instructions at https://developer.android.com/studio/command-line/bundletool.')
UI.user_error!('No AAB file path was specified and none was found in the lane context. Please specify the `aab_file_path` parameter or ensure that the relevant build action has been run prior to this action.')
44
-
raise
58
+
UI.user_error!(NO_AAB_ERROR_MESSAGE)
59
+
elsif !File.file?(aab_file_path)
60
+
UI.user_error!("The file `#{aab_file_path}` was not found. Please provide a path to an existing file.")
MISSING_BUNDLETOOL_ERROR_MESSAGE='bundletool is not installed. Please install it using the instructions at https://developer.android.com/studio/command-line/bundletool.'.freeze
67
+
NO_AAB_ERROR_MESSAGE='No AAB file path was specified and none was found in the lane context. Please specify the `aab_file_path` parameter or ensure that the `gradle` action has been run prior to this action.'.freeze
'Generates an APK file from the specified AAB file using `bundletool`'
66
79
end
67
80
68
81
defself.available_options
69
82
[
70
83
FastlaneCore::ConfigItem.new(
71
84
key: :aab_file_path,
72
85
env_name: 'ANDROID_AAB_FILE_PATH',
73
-
description: 'The path to the AAB file. If not speicified, the action will attempt to read from the lane context using the `SharedValues::GRADLE_ALL_AAB_OUTPUT_PATHS` and `SharedValues::GRADLE_AAB_OUTPUT_PATH` keys',
86
+
description: 'The path to the AAB file. If not specified, the action will attempt to read from the lane context using the `SharedValues::GRADLE_ALL_AAB_OUTPUT_PATHS` and `SharedValues::GRADLE_AAB_OUTPUT_PATH` keys',
74
87
type: String,
75
88
optional: true,
76
-
default_value: nil,
77
-
verify_block: proc{ |p| UI.user_error!("AAB path `#{p}` is not a valid file path.")unlessFile.file?(p)}
89
+
default_value: nil
78
90
),
79
91
FastlaneCore::ConfigItem.new(
80
92
key: :apk_output_file_path,
81
93
env_name: 'ANDROID_APK_OUTPUT_PATH',
82
-
description: 'The output path where the APK file will be generated. The directory will be created if it does not yet exist',
94
+
description: 'The path of the output APK file to generate. If not specified, will use the same path and basename as the `aab_file_path` but with an `.apk` file extension',
83
95
type: String,
84
-
optional: false,
96
+
optional: true,
85
97
default_value: nil
86
98
),
87
99
FastlaneCore::ConfigItem.new(
88
100
key: :keystore_path,
89
101
env_name: 'ANDROID_KEYSTORE_PATH',
90
-
description: 'The path to the keystore file',
102
+
description: 'The path to the keystore file (if you want to codesign the APK)',
91
103
type: String,
92
104
optional: true,
93
105
default_value: nil,
94
-
verify_block: proc{ |p| UI.user_error!("Keystore file path `#{p}` is not a valid file path.")unlessFile.file?(p) || p.nil}
106
+
verify_block: proc{ |p| UI.user_error!("Keystore file path `#{p}` is not a valid file path.")unlessp.nil? || File.file?(p)}
95
107
),
96
108
FastlaneCore::ConfigItem.new(
97
109
key: :keystore_password,
98
110
env_name: 'ANDROID_KEYSTORE_PASSWORD',
99
-
description: 'The password for the keystore',
111
+
description: 'The password for the keystore (if you want to codesign the APK)',
100
112
type: String,
101
113
optional: true,
102
114
default_value: nil
103
115
),
104
116
FastlaneCore::ConfigItem.new(
105
117
key: :keystore_key_alias,
106
118
env_name: 'ANDROID_KEYSTORE_KEY_ALIAS',
107
-
description: 'The alias of the key in the keystore',
119
+
description: 'The alias of the key in the keystore (if you want to codesign the APK)',
108
120
type: String,
109
121
optional: true,
110
122
default_value: nil
111
123
),
112
124
FastlaneCore::ConfigItem.new(
113
125
key: :signing_key_password,
114
126
env_name: 'ANDROID_SIGNING_KEY_PASSWORD',
115
-
description: 'The password for the signing key',
127
+
description: 'The password for the signing key (if you want to codesign the APK)',
0 commit comments