-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
104 lines (93 loc) · 2.3 KB
/
Copy pathmain.go
File metadata and controls
104 lines (93 loc) · 2.3 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package main
import (
"os"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
func main() {
// setup logging configuration
setupLogging()
cfg := &Configuration{}
app := &cli.App{
Name: "amalgam",
Usage: "Create macOS Universal binaries from Github releases",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "owner",
Required: true,
Usage: "Github repo owner username ",
Destination: &cfg.Owner,
},
&cli.StringFlag{
Name: "repo",
Required: true,
Usage: "Github repository name",
Destination: &cfg.Repository,
},
&cli.StringFlag{
Name: "tag",
Required: false,
Usage: "Github repository name",
Value: "latest",
Destination: &cfg.Tag,
},
&cli.StringFlag{
Name: "amd64",
Required: true,
Usage: "Substring for the amd64 binary",
Destination: &cfg.Amd64Substring,
},
&cli.StringFlag{
Name: "arm64",
Required: true,
Usage: "Substring for the arm64 binary",
Destination: &cfg.Arm64Substring,
},
&cli.BoolFlag{
Name: "compressed",
Required: false,
Usage: "Do the releases use compressed archives",
Destination: &cfg.Compressed,
},
&cli.BoolFlag{
Name: "overwrite",
Required: false,
Usage: "Delete pre-existing universal asset?",
Destination: &cfg.Overwrite,
},
&cli.StringFlag{
Name: "identifier",
Required: false,
Usage: "Identifier for universal binary",
Value: "all",
Destination: &cfg.UniversalIdentifer,
},
},
Action: func(context *cli.Context) error {
log.Debug("Num flags: ", context.NumFlags())
if context.NumFlags() < 4 {
cli.ShowAppHelpAndExit(context, 1)
}
token := os.Getenv("GITHUB_TOKEN")
if token == "" {
log.Fatal("GITHUB_TOKEN environment variable is empty.")
os.Exit(2)
}
cfg.GithubToken = token
err := CreateUniveralBinary(cfg)
if err != nil {
log.Fatal("Exiting. Encountered exception: ", err)
os.Exit(1)
}
log.Info("Complete.")
return nil
},
}
// run command line application and exit on error
err := app.Run(os.Args)
if err != nil {
log.Fatalf("Encountered error: %s", err.Error())
log.Fatal("Exiting...")
os.Exit(1)
}
}