fastlane-plugin-waldo 2.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +6 -12
- data/lib/fastlane/plugin/waldo/actions/waldo_action.rb +12 -15
- data/lib/fastlane/plugin/waldo/helper/waldo_helper.rb +104 -49
- data/lib/fastlane/plugin/waldo/version.rb +1 -1
- metadata +8 -9
- data/lib/fastlane/plugin/waldo/assets/WaldoCLI.sh +0 -672
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd1dc057170631344e00479670d7a24783fb646ed259d6c3dd24c70b03a0778f
|
4
|
+
data.tar.gz: e7cf97ce2e4ab0035ef472eb0c4e9eb28146afcfe421810101cf4e73972e646d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 450c1adf34a74785d8e13db163a59f5e806e6d3eb2e8779a83e19e78e61a15d41ef80b20270da18ce2041befe304a0d4ac23062ee3a16c4c1bc9639adcac2a08
|
7
|
+
data.tar.gz: 705cc3019a2dfcb221b0d1084a7a1c30014bbafceb534532d806b8badb6a12cba6395076d84cc4aad276bfd44ee1907f5d149b069636185f6c6a584863b8d057
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -38,8 +38,7 @@ gym(configuration: 'Release',
|
|
38
38
|
destination: 'generic/platform=iOS Simulator')
|
39
39
|
```
|
40
40
|
|
41
|
-
You can then find your app
|
42
|
-
data path:
|
41
|
+
You can then find your app relative to the derived data path:
|
43
42
|
|
44
43
|
```ruby
|
45
44
|
app_path = File.join(derived_data_path,
|
@@ -54,13 +53,11 @@ upload itself is very simple:
|
|
54
53
|
|
55
54
|
```ruby
|
56
55
|
waldo(upload_token: '0123456789abcdef0123456789abcdef',
|
57
|
-
app_path: '/path/to/YourApp.app'
|
58
|
-
include_symbols: true)
|
56
|
+
app_path: '/path/to/YourApp.app')
|
59
57
|
```
|
60
58
|
|
61
59
|
> **Note:** You _must_ specify _both_ the Waldo upload token _and_ the path of
|
62
|
-
> the `.app`.
|
63
|
-
> recommend supplying it.
|
60
|
+
> the `.app`.
|
64
61
|
|
65
62
|
### Uploading an iOS Device Build
|
66
63
|
|
@@ -70,20 +67,17 @@ your IPA, `waldo` will automatically find and upload the generated IPA.
|
|
70
67
|
```ruby
|
71
68
|
gym(export_method: 'ad-hoc') # or 'development'
|
72
69
|
|
73
|
-
waldo(upload_token: '0123456789abcdef0123456789abcdef'
|
74
|
-
dsym_path: lane_context[SharedValues::DSYM_OUTPUT_PATH])
|
70
|
+
waldo(upload_token: '0123456789abcdef0123456789abcdef')
|
75
71
|
```
|
76
72
|
|
77
|
-
> **Note:** You _must_ specify the Waldo upload token.
|
78
|
-
> parameter is optional but we highly recommend supplying it.
|
73
|
+
> **Note:** You _must_ specify the Waldo upload token.
|
79
74
|
|
80
75
|
If you do _not_ use `gym` to build your IPA, you will need to explicitly
|
81
76
|
specify the IPA path to `waldo`:
|
82
77
|
|
83
78
|
```ruby
|
84
79
|
waldo(upload_token: '0123456789abcdef0123456789abcdef',
|
85
|
-
ipa_path: '/path/to/YourApp.ipa'
|
86
|
-
dsym_path: '/path/to/YourApp.app.dSYM.zip')
|
80
|
+
ipa_path: '/path/to/YourApp.ipa')
|
87
81
|
```
|
88
82
|
|
89
83
|
### Uploading an Android Build
|
@@ -7,7 +7,7 @@ module Fastlane
|
|
7
7
|
FastlaneCore::PrintTable.print_values(config: mparams,
|
8
8
|
title: "Summary for waldo #{Fastlane::Waldo::VERSION.to_s}")
|
9
9
|
|
10
|
-
Helper::WaldoHelper.
|
10
|
+
Helper::WaldoHelper.upload_build(mparams)
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.authors
|
@@ -27,16 +27,6 @@ module Fastlane
|
|
27
27
|
default_value: Actions.lane_context[Actions::SharedValues::IPA_OUTPUT_PATH],
|
28
28
|
default_value_dynamic: true,
|
29
29
|
optional: true),
|
30
|
-
FastlaneCore::ConfigItem.new(key: :dsym_path,
|
31
|
-
env_name: 'WALDO_DSYM_PATH',
|
32
|
-
description: 'Path to your dSYM file(s)',
|
33
|
-
optional: true),
|
34
|
-
FastlaneCore::ConfigItem.new(key: :include_symbols,
|
35
|
-
env_name: 'WALDO_INCLUDE_SYMBOLS',
|
36
|
-
description: 'Include symbols in upload if true',
|
37
|
-
optional: true,
|
38
|
-
default_value: false,
|
39
|
-
is_string: false),
|
40
30
|
# Android-specific
|
41
31
|
FastlaneCore::ConfigItem.new(key: :apk_path,
|
42
32
|
env_name: 'WALDO_APK_PATH',
|
@@ -47,14 +37,21 @@ module Fastlane
|
|
47
37
|
# General
|
48
38
|
FastlaneCore::ConfigItem.new(key: :upload_token,
|
49
39
|
env_name: 'WALDO_UPLOAD_TOKEN',
|
50
|
-
description: '
|
40
|
+
description: 'Upload token',
|
51
41
|
optional: true,
|
52
42
|
sensitive: true),
|
53
43
|
FastlaneCore::ConfigItem.new(key: :variant_name,
|
54
44
|
env_name: 'WALDO_VARIANT_NAME',
|
55
|
-
description: '
|
56
|
-
optional: true,
|
57
|
-
|
45
|
+
description: 'Variant name',
|
46
|
+
optional: true),
|
47
|
+
FastlaneCore::ConfigItem.new(key: :git_branch,
|
48
|
+
env_name: 'WALDO_GIT_BRANCH',
|
49
|
+
description: 'Branch name for originating git commit',
|
50
|
+
optional: true),
|
51
|
+
FastlaneCore::ConfigItem.new(key: :git_commit,
|
52
|
+
env_name: 'WALDO_GIT_COMMIT',
|
53
|
+
description: 'Hash of originating git commit',
|
54
|
+
optional: true)
|
58
55
|
]
|
59
56
|
end
|
60
57
|
|
@@ -1,21 +1,88 @@
|
|
1
1
|
module Fastlane
|
2
2
|
module Helper
|
3
3
|
class WaldoHelper
|
4
|
+
require 'net/http'
|
5
|
+
|
6
|
+
def self.determine_asset_name
|
7
|
+
platform = RUBY_PLATFORM.downcase
|
8
|
+
|
9
|
+
if platform.include?('linux')
|
10
|
+
ext = ''
|
11
|
+
os = 'linux'
|
12
|
+
elsif platform.include?('darwin')
|
13
|
+
ext = ''
|
14
|
+
os = 'macos'
|
15
|
+
elsif platform.include?('mswin')
|
16
|
+
ext = '.exe'
|
17
|
+
os = 'windows'
|
18
|
+
else
|
19
|
+
UI.error("Unsupported platform: #{platform}")
|
20
|
+
end
|
21
|
+
|
22
|
+
if platform.include?('arm64')
|
23
|
+
arch = 'arm64'
|
24
|
+
elsif platform.include?('x86_64')
|
25
|
+
arch = 'x86_64'
|
26
|
+
else
|
27
|
+
UI.error("Unsupported platform: #{platform}")
|
28
|
+
end
|
29
|
+
|
30
|
+
"waldo-#{os}-#{arch}#{ext}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.download(uri, path)
|
34
|
+
begin
|
35
|
+
request_uri = uri.request_uri
|
36
|
+
response = nil
|
37
|
+
|
38
|
+
loop do
|
39
|
+
response = Net::HTTP.get_response(uri)
|
40
|
+
|
41
|
+
break unless response.is_a?(Net::HTTPRedirection)
|
42
|
+
|
43
|
+
uri = URI.parse(response['location'])
|
44
|
+
end
|
45
|
+
|
46
|
+
fp = File.open(path, 'wb')
|
47
|
+
|
48
|
+
fp.write(response.body)
|
49
|
+
rescue => exc
|
50
|
+
UI.error("Unable to download #{request_uri}: #{exc.inspect.to_s}")
|
51
|
+
ensure
|
52
|
+
fp.close if fp
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.download_binary
|
57
|
+
asset_name = determine_asset_name
|
58
|
+
|
59
|
+
uri_string = 'https://github.com/waldoapp/waldo-go-cli/releases/latest/download/'
|
60
|
+
|
61
|
+
uri_string += asset_name
|
62
|
+
|
63
|
+
binary_path = File.join(Dir.tmpdir, 'waldo')
|
64
|
+
|
65
|
+
download(URI(uri_string), binary_path)
|
66
|
+
|
67
|
+
File.chmod(0755, binary_path)
|
68
|
+
|
69
|
+
binary_path
|
70
|
+
end
|
71
|
+
|
4
72
|
def self.filter_parameters(in_params)
|
5
73
|
out_params = {}
|
6
74
|
|
7
75
|
apk_path = in_params[:apk_path]
|
8
76
|
app_path = in_params[:app_path]
|
9
|
-
|
10
|
-
|
77
|
+
git_branch = in_params[:git_branch]
|
78
|
+
git_commit = in_params[:git_commit]
|
11
79
|
ipa_path = in_params[:ipa_path]
|
12
80
|
upload_token = in_params[:upload_token]
|
13
81
|
variant_name = in_params[:variant_name] || Actions.lane_context[Actions::SharedValues::GRADLE_BUILD_TYPE]
|
14
82
|
|
15
|
-
apk_path.gsub!(
|
16
|
-
app_path.gsub!(
|
17
|
-
|
18
|
-
ipa_path.gsub!("\\ ", ' ') if ipa_path
|
83
|
+
apk_path.gsub!('\\ ', ' ') if apk_path
|
84
|
+
app_path.gsub!('\\ ', ' ') if app_path
|
85
|
+
ipa_path.gsub!('\\ ', ' ') if ipa_path
|
19
86
|
|
20
87
|
out_params[:apk_path] = apk_path if apk_path
|
21
88
|
|
@@ -42,72 +109,60 @@ module Fastlane
|
|
42
109
|
out_params[:ipa_path] = ipa_path if ipa_path
|
43
110
|
end
|
44
111
|
|
45
|
-
if
|
46
|
-
|
47
|
-
out_params[:include_symbols] = include_symbols if include_symbols
|
48
|
-
else
|
49
|
-
out_params[:dsym_path] = dsym_path if dsym_path && ipa_path
|
50
|
-
end
|
51
|
-
|
112
|
+
out_params[:git_branch] = git_branch if git_branch
|
113
|
+
out_params[:git_commit] = git_commit if git_commit
|
52
114
|
out_params[:upload_token] = upload_token if upload_token
|
53
115
|
out_params[:variant_name] = variant_name if variant_name
|
54
116
|
|
55
117
|
out_params
|
56
118
|
end
|
57
119
|
|
58
|
-
def self.
|
59
|
-
case get_platform
|
60
|
-
when :android
|
61
|
-
'Android'
|
62
|
-
when :ios
|
63
|
-
'iOS'
|
64
|
-
else
|
65
|
-
'unknown'
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.get_platform
|
70
|
-
Actions.lane_context[Actions::SharedValues::PLATFORM_NAME] || :ios
|
71
|
-
end
|
72
|
-
|
73
|
-
def self.get_script_path
|
74
|
-
root = Pathname.new(File.expand_path('../../..', __FILE__))
|
75
|
-
|
76
|
-
File.join(root, 'waldo', 'assets', 'WaldoCLI.sh')
|
77
|
-
end
|
78
|
-
|
79
|
-
def self.get_user_agent
|
80
|
-
"Waldo fastlane/#{get_flavor} v#{Fastlane::Waldo::VERSION}"
|
81
|
-
end
|
82
|
-
|
83
|
-
def self.upload_build_with_symbols(params)
|
120
|
+
def self.upload_build(params)
|
84
121
|
apk_path = params[:apk_path]
|
85
122
|
app_path = params[:app_path]
|
86
123
|
ipa_path = params[:ipa_path]
|
87
124
|
|
88
125
|
if apk_path
|
89
|
-
|
126
|
+
build_path = apk_path
|
90
127
|
elsif app_path
|
91
|
-
|
128
|
+
build_path = app_path
|
92
129
|
elsif ipa_path
|
93
|
-
|
130
|
+
build_path = ipa_path
|
94
131
|
else
|
95
|
-
|
132
|
+
build_path = ''
|
96
133
|
end
|
97
134
|
|
98
135
|
command = []
|
99
136
|
|
100
|
-
command << "
|
101
|
-
command << "
|
102
|
-
|
137
|
+
command << "WALDO_WRAPPER_NAME_OVERRIDE='Fastlane'"
|
138
|
+
command << "WALDO_WRAPPER_VERSION_OVERRIDE='#{Fastlane::Waldo::VERSION}'"
|
139
|
+
|
140
|
+
command << download_binary.shellescape
|
141
|
+
command << 'upload'
|
142
|
+
|
143
|
+
if params[:git_branch]
|
144
|
+
command << '--git_branch'
|
145
|
+
command << params[:git_branch]
|
146
|
+
end
|
103
147
|
|
104
|
-
|
148
|
+
if params[:git_commit]
|
149
|
+
command << '--git_commit'
|
150
|
+
command << params[:git_commit]
|
151
|
+
end
|
152
|
+
|
153
|
+
if params[:upload_token]
|
154
|
+
command << '--upload_token'
|
155
|
+
command << params[:upload_token]
|
156
|
+
end
|
157
|
+
|
158
|
+
if params[:variant_name]
|
159
|
+
command << '--variant_name'
|
160
|
+
command << params[:variant_name]
|
161
|
+
end
|
105
162
|
|
106
|
-
command << '--include_symbols' if params[:include_symbols]
|
107
163
|
command << '--verbose' if FastlaneCore::Globals.verbose?
|
108
164
|
|
109
165
|
command << build_path.shellescape
|
110
|
-
command << params[:dsym_path].shellescape if params[:dsym_path]
|
111
166
|
|
112
167
|
Actions.sh_control_output(command.join(' '),
|
113
168
|
print_command: FastlaneCore::Globals.verbose?,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-waldo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- John Pusey
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description:
|
70
70
|
email: john@waldo.io
|
71
71
|
executables: []
|
72
72
|
extensions: []
|
@@ -76,14 +76,13 @@ files:
|
|
76
76
|
- README.md
|
77
77
|
- lib/fastlane/plugin/waldo.rb
|
78
78
|
- lib/fastlane/plugin/waldo/actions/waldo_action.rb
|
79
|
-
- lib/fastlane/plugin/waldo/assets/WaldoCLI.sh
|
80
79
|
- lib/fastlane/plugin/waldo/helper/waldo_helper.rb
|
81
80
|
- lib/fastlane/plugin/waldo/version.rb
|
82
81
|
homepage: https://github.com/waldoapp/fastlane-plugin-waldo
|
83
82
|
licenses:
|
84
83
|
- MIT
|
85
84
|
metadata: {}
|
86
|
-
post_install_message:
|
85
|
+
post_install_message:
|
87
86
|
rdoc_options: []
|
88
87
|
require_paths:
|
89
88
|
- lib
|
@@ -98,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
97
|
- !ruby/object:Gem::Version
|
99
98
|
version: '0'
|
100
99
|
requirements: []
|
101
|
-
rubygems_version: 3.0.3
|
102
|
-
signing_key:
|
100
|
+
rubygems_version: 3.0.3.1
|
101
|
+
signing_key:
|
103
102
|
specification_version: 4
|
104
103
|
summary: Upload build to Waldo
|
105
104
|
test_files: []
|
@@ -1,672 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
set -eu -o pipefail
|
4
|
-
|
5
|
-
waldo_api_build_endpoint=${WALDO_API_BUILD_ENDPOINT:-https://api.waldo.io/versions}
|
6
|
-
waldo_api_error_endpoint=${WALDO_API_ERROR_ENDPOINT:-https://api.waldo.io/uploadError}
|
7
|
-
waldo_api_symbols_endpoint=${WALDO_API_SYMBOLS_ENDPOINT:-https://api.waldo.io/versions/__ID__/symbols}
|
8
|
-
waldo_user_agent_override=${WALDO_USER_AGENT_OVERRIDE:-}
|
9
|
-
|
10
|
-
waldo_cli_version="1.6.6"
|
11
|
-
|
12
|
-
waldo_build_flavor=""
|
13
|
-
waldo_build_path=""
|
14
|
-
waldo_build_payload_path=""
|
15
|
-
waldo_build_suffix=""
|
16
|
-
waldo_build_upload_id=""
|
17
|
-
waldo_extra_args="--show-error --silent"
|
18
|
-
waldo_history=""
|
19
|
-
waldo_history_error=""
|
20
|
-
waldo_include_symbols=false
|
21
|
-
waldo_platform=""
|
22
|
-
waldo_symbols_path=""
|
23
|
-
waldo_symbols_payload_path=""
|
24
|
-
waldo_symbols_suffix=""
|
25
|
-
waldo_upload_token=""
|
26
|
-
waldo_variant_name=""
|
27
|
-
waldo_working_path=""
|
28
|
-
|
29
|
-
function abs_path() {
|
30
|
-
local _rel_path=$1
|
31
|
-
|
32
|
-
[[ -n $_rel_path ]] || _rel_path="."
|
33
|
-
|
34
|
-
case "$_rel_path" in
|
35
|
-
.) pwd ;;
|
36
|
-
..) (unset CDPATH && cd .. &>/dev/null && pwd) ;;
|
37
|
-
/*) echo $_rel_path ;;
|
38
|
-
*) local _dirname=$(dirname "$_rel_path")
|
39
|
-
|
40
|
-
_dirname=$(unset CDPATH && cd "$_dirname" &>/dev/null && pwd)
|
41
|
-
|
42
|
-
if [[ -n $_dirname ]]; then
|
43
|
-
echo ${_dirname}/$(basename "$_rel_path")
|
44
|
-
else
|
45
|
-
echo $_rel_path
|
46
|
-
fi
|
47
|
-
;;
|
48
|
-
esac
|
49
|
-
}
|
50
|
-
|
51
|
-
function check_build_path() {
|
52
|
-
[[ -n $waldo_build_path ]] || fail_usage "Missing required argument: ‘path’"
|
53
|
-
|
54
|
-
waldo_build_path=$(abs_path "$waldo_build_path")
|
55
|
-
waldo_build_suffix=${waldo_build_path##*.}
|
56
|
-
|
57
|
-
case $waldo_build_suffix in
|
58
|
-
apk) waldo_build_flavor="Android" ;;
|
59
|
-
app|ipa) waldo_build_flavor="iOS" ;;
|
60
|
-
*) fail "File extension of build at ‘${waldo_build_path}’ is not recognized" ;;
|
61
|
-
esac
|
62
|
-
}
|
63
|
-
|
64
|
-
function check_build_status() {
|
65
|
-
local _response=$1
|
66
|
-
|
67
|
-
local _status_regex='"status":([0-9]+)'
|
68
|
-
|
69
|
-
if [[ $_response =~ $_status_regex ]]; then
|
70
|
-
local _status=${BASH_REMATCH[1]}
|
71
|
-
|
72
|
-
if (( $_status == 401 )); then
|
73
|
-
fail "Upload token is invalid or missing!"
|
74
|
-
elif (( $_status < 200 || $_status > 299 )); then
|
75
|
-
fail "Unable to upload build to Waldo, HTTP status: $_status"
|
76
|
-
fi
|
77
|
-
fi
|
78
|
-
|
79
|
-
local _id_regex='"id":"(appv-[0-9a-f]+)"'
|
80
|
-
|
81
|
-
if [[ $_response =~ $_id_regex ]]; then
|
82
|
-
waldo_build_upload_id=${BASH_REMATCH[1]}
|
83
|
-
fi
|
84
|
-
}
|
85
|
-
|
86
|
-
function check_history() {
|
87
|
-
if [[ -z $(which base64) ]]; then
|
88
|
-
waldo_history_error="noBase64CommandFound"
|
89
|
-
elif [[ -z $(which git) ]]; then
|
90
|
-
waldo_history_error="noGitCommandFound"
|
91
|
-
elif [[ -z $(which grep) ]]; then
|
92
|
-
waldo_history_error="noGrepCommandFound"
|
93
|
-
elif [[ -z $(which sed) ]]; then
|
94
|
-
waldo_history_error="noSedCommandFound"
|
95
|
-
elif [[ -z $(which tr) ]]; then
|
96
|
-
waldo_history_error="noTrCommandFound"
|
97
|
-
elif ! git rev-parse >& /dev/null; then
|
98
|
-
waldo_history_error="notGitRepository"
|
99
|
-
else
|
100
|
-
waldo_history=$(get_history)
|
101
|
-
fi
|
102
|
-
}
|
103
|
-
|
104
|
-
function check_platform() {
|
105
|
-
if [[ -z $(which curl) ]]; then
|
106
|
-
fail "No ‘curl’ command found"
|
107
|
-
fi
|
108
|
-
}
|
109
|
-
|
110
|
-
function check_symbols_path() {
|
111
|
-
case $waldo_build_suffix in
|
112
|
-
app)
|
113
|
-
if [[ -z $waldo_symbols_path && $waldo_include_symbols == true ]]; then
|
114
|
-
waldo_symbols_path=$(find_symbols_path)
|
115
|
-
fi
|
116
|
-
;;
|
117
|
-
ipa) ;;
|
118
|
-
*) waldo_symbols_path="" ;; # not applicable
|
119
|
-
esac
|
120
|
-
|
121
|
-
[[ -n $waldo_symbols_path ]] || return 0
|
122
|
-
|
123
|
-
waldo_symbols_path=$(abs_path "$waldo_symbols_path")
|
124
|
-
waldo_symbols_suffix=${waldo_symbols_path##*.}
|
125
|
-
|
126
|
-
case $waldo_symbols_suffix in
|
127
|
-
dSYM|xcarchive|zip) ;; # OK
|
128
|
-
*) fail "File extension of symbols at ‘${waldo_symbols_path}’ is not recognized" ;;
|
129
|
-
esac
|
130
|
-
}
|
131
|
-
|
132
|
-
function check_symbols_status() {
|
133
|
-
local _response=$1
|
134
|
-
|
135
|
-
local _status_regex='"status":([0-9]+)'
|
136
|
-
|
137
|
-
if [[ $_response =~ $_status_regex ]]; then
|
138
|
-
local _status=${BASH_REMATCH[1]}
|
139
|
-
|
140
|
-
if (( $_status == 401 )); then
|
141
|
-
fail "Upload token is invalid or missing!"
|
142
|
-
elif (( $_status < 200 || $_status > 299 )); then
|
143
|
-
fail "Unable to upload symbols to Waldo, HTTP status: $_status"
|
144
|
-
fi
|
145
|
-
fi
|
146
|
-
}
|
147
|
-
|
148
|
-
function check_upload_token() {
|
149
|
-
[[ -n $waldo_upload_token ]] || waldo_upload_token=${WALDO_UPLOAD_TOKEN:-}
|
150
|
-
[[ -n $waldo_upload_token ]] || fail_usage "Missing required option: ‘--upload_token’"
|
151
|
-
}
|
152
|
-
|
153
|
-
function check_variant_name() {
|
154
|
-
[[ -n $waldo_variant_name ]] || waldo_variant_name=${WALDO_VARIANT_NAME:-}
|
155
|
-
}
|
156
|
-
|
157
|
-
function convert_sha() {
|
158
|
-
local _full_sha=$1
|
159
|
-
local _full_name=$(git name-rev --refs='heads/*' --name-only "$_full_sha")
|
160
|
-
local _abbr_sha=${_full_sha:0:7}
|
161
|
-
local _abbr_name=$_full_name
|
162
|
-
local _prefix="remotes/origin/"
|
163
|
-
|
164
|
-
if [[ ${_full_name:0:${#_prefix}} == $_prefix ]]; then
|
165
|
-
_abbr_name=${_full_name#$_prefix}
|
166
|
-
else
|
167
|
-
_abbr_name="local:${_full_name}"
|
168
|
-
fi
|
169
|
-
|
170
|
-
echo "${_abbr_sha}-${_abbr_name}"
|
171
|
-
}
|
172
|
-
|
173
|
-
function convert_shas() {
|
174
|
-
local _list=
|
175
|
-
|
176
|
-
while (( $# )); do
|
177
|
-
local _item=$(convert_sha "$1")
|
178
|
-
|
179
|
-
_list+=",\"${_item}\""
|
180
|
-
|
181
|
-
shift
|
182
|
-
done
|
183
|
-
|
184
|
-
echo ${_list#?}
|
185
|
-
}
|
186
|
-
|
187
|
-
function create_build_payload() {
|
188
|
-
local _parent_path=$(dirname "$waldo_build_path")
|
189
|
-
local _build_name=$(basename "$waldo_build_path")
|
190
|
-
|
191
|
-
case $waldo_build_suffix in
|
192
|
-
app)
|
193
|
-
([[ -d $waldo_build_path && -r $waldo_build_path ]]) \
|
194
|
-
|| fail "Unable to read build at ‘${waldo_build_path}’"
|
195
|
-
|
196
|
-
if [[ -z $(which zip) ]]; then
|
197
|
-
fail "No ‘zip’ command found"
|
198
|
-
fi
|
199
|
-
|
200
|
-
waldo_build_payload_path="$waldo_working_path"/"$_build_name".zip
|
201
|
-
|
202
|
-
(cd "$_parent_path" &>/dev/null && zip -qry "$waldo_build_payload_path" "$_build_name") || return
|
203
|
-
;;
|
204
|
-
|
205
|
-
*)
|
206
|
-
([[ -f $waldo_build_path && -r $waldo_build_path ]]) \
|
207
|
-
|| fail "Unable to read build at ‘${waldo_build_path}’"
|
208
|
-
|
209
|
-
waldo_build_payload_path=$waldo_build_path
|
210
|
-
;;
|
211
|
-
esac
|
212
|
-
}
|
213
|
-
|
214
|
-
function create_symbols_payload() {
|
215
|
-
[[ -n $waldo_symbols_path ]] || return 0
|
216
|
-
|
217
|
-
local _parent_path=$(dirname "$waldo_symbols_path")
|
218
|
-
local _symbols_name=$(basename "$waldo_symbols_path")
|
219
|
-
|
220
|
-
case $waldo_symbols_suffix in
|
221
|
-
dSYM)
|
222
|
-
([[ -d $waldo_symbols_path && -r $waldo_symbols_path ]]) \
|
223
|
-
|| fail "Unable to read symbols at ‘${waldo_symbols_path}’"
|
224
|
-
|
225
|
-
if [[ -z $(which zip) ]]; then
|
226
|
-
fail "No ‘zip’ command found"
|
227
|
-
fi
|
228
|
-
|
229
|
-
waldo_symbols_payload_path="$waldo_working_path"/"$_symbols_name".zip
|
230
|
-
|
231
|
-
(cd "$_parent_path" &>/dev/null && zip -qry "$waldo_symbols_payload_path" "$_symbols_name") || return
|
232
|
-
;;
|
233
|
-
|
234
|
-
xcarchive)
|
235
|
-
([[ -d $waldo_symbols_path && -r $waldo_symbols_path ]]) \
|
236
|
-
|| fail "Unable to read symbols at ‘${waldo_symbols_path}’"
|
237
|
-
|
238
|
-
if [[ -z $(which zip) ]]; then
|
239
|
-
fail "No ‘zip’ command found"
|
240
|
-
fi
|
241
|
-
|
242
|
-
local _tmp_symbols_path="$waldo_working_path"/"$_symbols_name"
|
243
|
-
|
244
|
-
mkdir -p "$_tmp_symbols_path"
|
245
|
-
|
246
|
-
cp -r "$waldo_symbols_path"/BCSymbolMaps "$_tmp_symbols_path"
|
247
|
-
cp -r "$waldo_symbols_path"/dSYMs "$_tmp_symbols_path"
|
248
|
-
|
249
|
-
waldo_symbols_payload_path="$_tmp_symbols_path".zip
|
250
|
-
|
251
|
-
(cd "$waldo_working_path" &>/dev/null && zip -qry "$waldo_symbols_payload_path" "$_symbols_name") || return
|
252
|
-
;;
|
253
|
-
|
254
|
-
*)
|
255
|
-
([[ -f $waldo_symbols_path && -r $waldo_symbols_path ]]) \
|
256
|
-
|| fail "Unable to read symbols at ‘${waldo_symbols_path}’"
|
257
|
-
|
258
|
-
waldo_symbols_payload_path=$waldo_symbols_path
|
259
|
-
;;
|
260
|
-
esac
|
261
|
-
}
|
262
|
-
|
263
|
-
function create_working_path() {
|
264
|
-
waldo_working_path=/tmp/WaldoCLI-$$
|
265
|
-
|
266
|
-
rm -rf "$waldo_working_path"
|
267
|
-
mkdir -p "$waldo_working_path"
|
268
|
-
}
|
269
|
-
|
270
|
-
function curl_upload_build() {
|
271
|
-
local _output_path="$1"
|
272
|
-
local _authorization=$(get_authorization)
|
273
|
-
local _content_type=$(get_build_content_type)
|
274
|
-
local _user_agent=$(get_user_agent)
|
275
|
-
local _url=$(make_build_url)
|
276
|
-
|
277
|
-
curl $waldo_extra_args \
|
278
|
-
--data-binary @"$waldo_build_payload_path" \
|
279
|
-
--header "Authorization: $_authorization" \
|
280
|
-
--header "Content-Type: $_content_type" \
|
281
|
-
--header "User-Agent: $_user_agent" \
|
282
|
-
--output "$_output_path" \
|
283
|
-
"$_url"
|
284
|
-
|
285
|
-
local _curl_status=$?
|
286
|
-
|
287
|
-
if (( $_curl_status != 0 )); then
|
288
|
-
fail "Unable to upload build to Waldo, curl error: ${_curl_status}, url: ${_url}"
|
289
|
-
fi
|
290
|
-
}
|
291
|
-
|
292
|
-
function curl_upload_error() {
|
293
|
-
local _message=$(json_escape "$1")
|
294
|
-
local _ci=$(get_ci)
|
295
|
-
local _authorization=$(get_authorization)
|
296
|
-
local _content_type=$(get_error_content_type)
|
297
|
-
local _user_agent=$(get_user_agent)
|
298
|
-
local _url=$(make_error_url)
|
299
|
-
|
300
|
-
curl --silent \
|
301
|
-
--data "{\"message\":\"${_message}\",\"ci\":\"${_ci}\"}" \
|
302
|
-
--header "Authorization: $_authorization" \
|
303
|
-
--header "Content-Type: $_content_type" \
|
304
|
-
--header "User-Agent: $_user_agent" \
|
305
|
-
"$_url" &>/dev/null
|
306
|
-
}
|
307
|
-
|
308
|
-
function curl_upload_symbols() {
|
309
|
-
local _output_path="$1"
|
310
|
-
local _authorization=$(get_authorization)
|
311
|
-
local _content_type=$(get_symbols_content_type)
|
312
|
-
local _user_agent=$(get_user_agent)
|
313
|
-
local _url=$(make_symbols_url)
|
314
|
-
|
315
|
-
curl $waldo_extra_args \
|
316
|
-
--data-binary @"$waldo_symbols_payload_path" \
|
317
|
-
--header "Authorization: $_authorization" \
|
318
|
-
--header "Content-Type: $_content_type" \
|
319
|
-
--header "User-Agent: $_user_agent" \
|
320
|
-
--output "$_output_path" \
|
321
|
-
"$_url"
|
322
|
-
|
323
|
-
local _curl_status=$?
|
324
|
-
|
325
|
-
if (( $_curl_status != 0 )); then
|
326
|
-
fail "Unable to upload symbols to Waldo, curl error: ${_curl_status}, url: ${_url}"
|
327
|
-
fi
|
328
|
-
}
|
329
|
-
|
330
|
-
function delete_working_path() {
|
331
|
-
if [[ -n $waldo_working_path ]]; then
|
332
|
-
rm -rf "$waldo_working_path"
|
333
|
-
fi
|
334
|
-
}
|
335
|
-
|
336
|
-
function display_summary() {
|
337
|
-
echo ""
|
338
|
-
echo "Build path: $(summarize "$waldo_build_path")"
|
339
|
-
echo "Symbols path: $(summarize "$waldo_symbols_path")"
|
340
|
-
echo "Variant name: $(summarize "$waldo_variant_name")"
|
341
|
-
echo "Upload token: $(summarize_secure "$waldo_upload_token")"
|
342
|
-
echo ""
|
343
|
-
|
344
|
-
if [[ $waldo_extra_args == "--verbose" ]]; then
|
345
|
-
echo "Build payload path: $(summarize "$waldo_build_payload_path")"
|
346
|
-
echo "Symbols payload path: $(summarize "$waldo_symbols_payload_path")"
|
347
|
-
echo ""
|
348
|
-
fi
|
349
|
-
}
|
350
|
-
|
351
|
-
function display_usage() {
|
352
|
-
cat <<EOF
|
353
|
-
|
354
|
-
OVERVIEW: Upload build to Waldo
|
355
|
-
|
356
|
-
USAGE: waldo [options] <build-path> [<symbols-path>]
|
357
|
-
|
358
|
-
OPTIONS:
|
359
|
-
|
360
|
-
--help Display available options
|
361
|
-
--include_symbols Include symbols with the build upload
|
362
|
-
--upload_token <value> Waldo upload token (overrides WALDO_UPLOAD_TOKEN)
|
363
|
-
--variant_name <value> Waldo variant name (overrides WALDO_VARIANT_NAME)
|
364
|
-
--verbose Display extra verbiage
|
365
|
-
EOF
|
366
|
-
}
|
367
|
-
|
368
|
-
function display_version() {
|
369
|
-
waldo_platform=$(get_platform)
|
370
|
-
|
371
|
-
echo "Waldo CLI $waldo_cli_version ($waldo_platform)"
|
372
|
-
}
|
373
|
-
|
374
|
-
function fail() {
|
375
|
-
local _message="waldo: $1"
|
376
|
-
|
377
|
-
if [[ -n $waldo_upload_token ]]; then
|
378
|
-
curl_upload_error "$1"
|
379
|
-
|
380
|
-
local _curl_status=$?
|
381
|
-
|
382
|
-
if (( $_curl_status == 0)); then
|
383
|
-
_message+=" -- Waldo team has been informed"
|
384
|
-
fi
|
385
|
-
fi
|
386
|
-
|
387
|
-
echo "" # flush stdout
|
388
|
-
echo "$_message" 1>&2
|
389
|
-
exit 1
|
390
|
-
}
|
391
|
-
|
392
|
-
function fail_usage() {
|
393
|
-
[[ -z $waldo_upload_token ]] || curl_upload_error "$1"
|
394
|
-
|
395
|
-
echo "" # flush stdout
|
396
|
-
echo "waldo: $1" 1>&2
|
397
|
-
display_usage
|
398
|
-
exit 1
|
399
|
-
}
|
400
|
-
|
401
|
-
function find_symbols_path() {
|
402
|
-
if [[ -e ${waldo_build_path}.dSYM.zip ]]; then
|
403
|
-
echo "${waldo_build_path}.dSYM.zip"
|
404
|
-
elif [[ -e ${waldo_build_path}.dSYM ]]; then
|
405
|
-
echo "${waldo_build_path}.dSYM"
|
406
|
-
fi
|
407
|
-
}
|
408
|
-
|
409
|
-
function get_authorization() {
|
410
|
-
echo "Upload-Token $waldo_upload_token"
|
411
|
-
}
|
412
|
-
|
413
|
-
function get_build_content_type() {
|
414
|
-
case $waldo_build_suffix in
|
415
|
-
app) echo "application/zip" ;;
|
416
|
-
*) echo "application/octet-stream" ;;
|
417
|
-
esac
|
418
|
-
}
|
419
|
-
|
420
|
-
function get_ci() {
|
421
|
-
if [[ -n ${APPCENTER_BUILD_ID:-} ]]; then
|
422
|
-
echo "App Center"
|
423
|
-
elif [[ ${BITRISE_IO:-false} == true ]]; then
|
424
|
-
echo "Bitrise"
|
425
|
-
elif [[ -n ${BUDDYBUILD_BUILD_ID:-} ]]; then
|
426
|
-
echo "buddybuild"
|
427
|
-
elif [[ ${CIRCLECI:-false} == true ]]; then
|
428
|
-
echo "CircleCI"
|
429
|
-
elif [[ ${GITHUB_ACTIONS:-false} == true ]]; then
|
430
|
-
echo "GitHub Actions"
|
431
|
-
elif [[ ${TRAVIS:-false} == true ]]; then
|
432
|
-
echo "Travis CI"
|
433
|
-
else
|
434
|
-
echo "CLI"
|
435
|
-
fi
|
436
|
-
}
|
437
|
-
|
438
|
-
function get_error_content_type() {
|
439
|
-
echo "application/json"
|
440
|
-
}
|
441
|
-
|
442
|
-
function get_history() {
|
443
|
-
local _shas=$(git log --format='%H' --skip=$(get_skip_count) -50)
|
444
|
-
local _history=$(convert_shas $_shas)
|
445
|
-
|
446
|
-
echo "[${_history}]" | websafe_base64_encode
|
447
|
-
}
|
448
|
-
|
449
|
-
function get_platform() {
|
450
|
-
local _os_name=$(uname -s)
|
451
|
-
|
452
|
-
case $_os_name in
|
453
|
-
Darwin) echo "macOS" ;;
|
454
|
-
*) echo "$_os_name" ;;
|
455
|
-
esac
|
456
|
-
}
|
457
|
-
|
458
|
-
function get_skip_count() {
|
459
|
-
if [[ ${GITHUB_ACTIONS:-false} == true && ${GITHUB_EVENT_NAME:-} == "pull_request" ]]; then
|
460
|
-
echo "1"
|
461
|
-
else
|
462
|
-
echo "0"
|
463
|
-
fi
|
464
|
-
}
|
465
|
-
|
466
|
-
function get_symbols_content_type() {
|
467
|
-
echo "application/zip"
|
468
|
-
}
|
469
|
-
|
470
|
-
function get_user_agent() {
|
471
|
-
if [[ -n $waldo_user_agent_override ]]; then
|
472
|
-
echo "$waldo_user_agent_override"
|
473
|
-
else
|
474
|
-
echo "Waldo $(get_ci)/${waldo_build_flavor} v${waldo_cli_version}"
|
475
|
-
fi
|
476
|
-
}
|
477
|
-
|
478
|
-
function json_escape() {
|
479
|
-
local _result=${1//\\/\\\\} # \
|
480
|
-
|
481
|
-
_result=${_result//\//\\\/} # /
|
482
|
-
_result=${_result//\'/\\\'} # '
|
483
|
-
_result=${_result//\"/\\\"} # "
|
484
|
-
|
485
|
-
echo "$_result"
|
486
|
-
}
|
487
|
-
|
488
|
-
function make_build_url() {
|
489
|
-
local _query=
|
490
|
-
|
491
|
-
if [[ -n $waldo_history ]]; then
|
492
|
-
_query+="&history=$waldo_history"
|
493
|
-
fi
|
494
|
-
|
495
|
-
if [[ -n $waldo_history_error ]]; then
|
496
|
-
_query+="&historyError=$waldo_history_error"
|
497
|
-
fi
|
498
|
-
|
499
|
-
if [[ -n $waldo_variant_name ]]; then
|
500
|
-
_query+="&variantName=$waldo_variant_name"
|
501
|
-
fi
|
502
|
-
|
503
|
-
if [[ -n $_query ]]; then
|
504
|
-
echo "${waldo_api_build_endpoint}?${_query:1}"
|
505
|
-
else
|
506
|
-
echo "${waldo_api_build_endpoint}"
|
507
|
-
fi
|
508
|
-
}
|
509
|
-
|
510
|
-
function make_error_url() {
|
511
|
-
echo "${waldo_api_error_endpoint}"
|
512
|
-
}
|
513
|
-
|
514
|
-
function make_symbols_url() {
|
515
|
-
echo "${waldo_api_symbols_endpoint/__ID__/$waldo_build_upload_id}"
|
516
|
-
}
|
517
|
-
|
518
|
-
function summarize() {
|
519
|
-
local _value=$1
|
520
|
-
|
521
|
-
if [[ -n $_value ]]; then
|
522
|
-
echo "‘${_value}’"
|
523
|
-
else
|
524
|
-
echo "(none)"
|
525
|
-
fi
|
526
|
-
}
|
527
|
-
|
528
|
-
function summarize_secure() {
|
529
|
-
local _value=$1
|
530
|
-
|
531
|
-
if [[ $waldo_extra_args != "--verbose" ]]; then
|
532
|
-
local _prefix=${_value:0:6}
|
533
|
-
local _suffix_len=$(( ${#_value} - ${#_prefix} ))
|
534
|
-
local _secure='********************************'
|
535
|
-
|
536
|
-
_value="${_prefix}${_secure:0:$_suffix_len}"
|
537
|
-
fi
|
538
|
-
|
539
|
-
summarize "$_value"
|
540
|
-
}
|
541
|
-
|
542
|
-
function upload_build() {
|
543
|
-
local _build_name=$(basename "$waldo_build_path")
|
544
|
-
|
545
|
-
local _response_path=$waldo_working_path/build_response.json
|
546
|
-
|
547
|
-
echo "Uploading build to Waldo"
|
548
|
-
|
549
|
-
[[ $waldo_extra_args == "--verbose" ]] && echo ""
|
550
|
-
|
551
|
-
curl_upload_build "$_response_path"
|
552
|
-
|
553
|
-
local _curl_status=$?
|
554
|
-
local _response=$(cat "$_response_path" 2>/dev/null)
|
555
|
-
|
556
|
-
if [[ $waldo_extra_args == "--verbose" ]]; then
|
557
|
-
echo "$_response"
|
558
|
-
echo ""
|
559
|
-
fi
|
560
|
-
|
561
|
-
check_build_status "$_response"
|
562
|
-
|
563
|
-
if (( $_curl_status == 0 )); then
|
564
|
-
echo "Build ‘${_build_name}’ successfully uploaded to Waldo!"
|
565
|
-
fi
|
566
|
-
}
|
567
|
-
|
568
|
-
function upload_symbols() {
|
569
|
-
[[ -n $waldo_symbols_path ]] || return 0
|
570
|
-
|
571
|
-
local _symbols_name=$(basename "$waldo_symbols_path")
|
572
|
-
|
573
|
-
local _response_path=$waldo_working_path/symbols_response.json
|
574
|
-
|
575
|
-
echo "Uploading symbols to Waldo"
|
576
|
-
|
577
|
-
[[ $waldo_extra_args == "--verbose" ]] && echo ""
|
578
|
-
|
579
|
-
curl_upload_symbols "$_response_path"
|
580
|
-
|
581
|
-
local _curl_status=$?
|
582
|
-
local _response=$(cat "$_response_path" 2>/dev/null)
|
583
|
-
|
584
|
-
if [[ $waldo_extra_args == "--verbose" ]]; then
|
585
|
-
echo "$_response"
|
586
|
-
echo ""
|
587
|
-
fi
|
588
|
-
|
589
|
-
check_symbols_status "$_response"
|
590
|
-
|
591
|
-
if (( $_curl_status == 0 )); then
|
592
|
-
echo "Symbols in ‘${_symbols_name}’ successfully uploaded to Waldo!"
|
593
|
-
fi
|
594
|
-
}
|
595
|
-
|
596
|
-
function websafe_base64_encode() {
|
597
|
-
base64 | tr -d '\n' | tr '/+' '_-' | sed 's/=/%3D/g'
|
598
|
-
}
|
599
|
-
|
600
|
-
display_version
|
601
|
-
|
602
|
-
while (( $# )); do
|
603
|
-
case $1 in
|
604
|
-
--help)
|
605
|
-
display_usage
|
606
|
-
exit
|
607
|
-
;;
|
608
|
-
|
609
|
-
--include_symbols)
|
610
|
-
waldo_include_symbols=true
|
611
|
-
;;
|
612
|
-
|
613
|
-
--upload_token)
|
614
|
-
if (( $# < 2 )) || [[ -z $2 || ${2:0:1} == "-" ]]; then
|
615
|
-
fail_usage "Missing required value for option: ‘${1}’"
|
616
|
-
else
|
617
|
-
waldo_upload_token=$2
|
618
|
-
shift
|
619
|
-
fi
|
620
|
-
;;
|
621
|
-
|
622
|
-
--variant_name)
|
623
|
-
if (( $# < 2 )) || [[ -z $2 || ${2:0:1} == "-" ]]; then
|
624
|
-
fail_usage "Missing required value for option: ‘${1}’"
|
625
|
-
else
|
626
|
-
waldo_variant_name=$2
|
627
|
-
shift
|
628
|
-
fi
|
629
|
-
;;
|
630
|
-
|
631
|
-
--verbose)
|
632
|
-
waldo_extra_args="--verbose"
|
633
|
-
;;
|
634
|
-
|
635
|
-
-*)
|
636
|
-
fail_usage "Unknown option: ‘${1}’"
|
637
|
-
;;
|
638
|
-
|
639
|
-
*)
|
640
|
-
if [[ -z $waldo_build_path ]]; then
|
641
|
-
waldo_build_path=$1
|
642
|
-
elif [[ -z $waldo_symbols_path ]]; then
|
643
|
-
waldo_symbols_path=$1
|
644
|
-
else
|
645
|
-
fail_usage "Unknown argument: ‘${1}’"
|
646
|
-
fi
|
647
|
-
;;
|
648
|
-
esac
|
649
|
-
|
650
|
-
shift
|
651
|
-
done
|
652
|
-
|
653
|
-
check_platform || exit
|
654
|
-
check_build_path || exit
|
655
|
-
check_symbols_path || exit
|
656
|
-
check_history || exit
|
657
|
-
check_upload_token || exit
|
658
|
-
check_variant_name || exit
|
659
|
-
|
660
|
-
create_working_path || exit
|
661
|
-
|
662
|
-
create_build_payload || exit
|
663
|
-
create_symbols_payload || exit
|
664
|
-
|
665
|
-
display_summary
|
666
|
-
|
667
|
-
upload_build || exit
|
668
|
-
upload_symbols || exit
|
669
|
-
|
670
|
-
delete_working_path # failure is OK
|
671
|
-
|
672
|
-
exit
|