forked from SimonRice/bitrise-step-sentry-upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
70 lines (60 loc) · 1.57 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"errors"
"fmt"
"os"
"github.com/bitrise-io/go-steputils/stepconf"
)
func delegatePlatformUploads(cfg Config, cmd CommandExecutor) ([]byte, error) {
uploads := []SentryCommand{}
dsym := SentryCommand{
Command: uploadDifCmd,
FilePath: cfg.DsymPath,
}
proguard := SentryCommand{
Command: uploadProguardCmd,
FilePath: cfg.ProguardPath,
}
if cfg.SelectedPlatform == "ios" {
uploads = append(uploads, dsym)
} else if cfg.SelectedPlatform == "android" {
uploads = append(uploads, proguard)
} else if cfg.SelectedPlatform == "both" {
uploads = append(uploads, dsym, proguard)
} else {
return nil, errors.New("Error: selected_platform invalid")
}
for _, upload := range uploads {
out, err := uploadSymbols(cfg, upload, cmd)
if err != nil {
return out, err
}
fmt.Printf("%s", out)
}
return []byte("Uploads completed"), nil
}
func uploadSymbols(cfg Config, sentry SentryCommand, cmd CommandExecutor) ([]byte, error) {
args := buildSentryArgs(cfg, sentry.Command)
args = append(args, sentry.FilePath)
if cfg.IsDebugMode == "true" {
args = append(args, logDebugArg)
}
fmt.Println(fmt.Sprintf("Executing %s, uploading %s...", sentry.Command, sentry.FilePath))
return cmd.execute(sentryCli, args...)
}
func main() {
var cfg Config
if err := stepconf.Parse(&cfg); err != nil {
fmt.Fprintf(os.Stderr, "Error: %s\n", err)
os.Exit(1)
}
stepconf.Print(cfg)
cmd := StepExecutor{}
out, err := delegatePlatformUploads(cfg, cmd)
if err != nil {
fmt.Printf("%s\n", err)
fmt.Printf("%s", string(out))
os.Exit(1)
}
os.Exit(0)
}