forked from projectcalico/calico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
84 lines (70 loc) · 1.86 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package main
import (
"flag"
"io"
"os"
"github.com/sirupsen/logrus"
lumberjack "gopkg.in/natefinch/lumberjack.v2"
"github.com/dtest11/calico/hack/release/pkg/builder"
)
var create, publish, newBranch, meta bool
var dir string
func init() {
flag.BoolVar(&create, "create", false, "Create a release from the current commit")
flag.BoolVar(&publish, "publish", false, "Publish the release built from the current tag")
flag.BoolVar(&newBranch, "new-branch", false, "Create a new release branch from master")
flag.BoolVar(&meta, "metadata", false, "Product release metadata")
flag.StringVar(&dir, "dir", "./", "Directory to place build metadata in")
flag.Parse()
}
func main() {
// Create a releaseBuilder to use.
r := builder.NewReleaseBuilder(&builder.RealCommandRunner{})
if meta {
configureLogging("metadata.log")
err := r.BuildMetadata(dir)
if err != nil {
logrus.WithError(err).Error("Failed to produce release metadata")
os.Exit(1)
}
return
}
if create {
configureLogging("release-build.log")
err := r.BuildRelease()
if err != nil {
logrus.WithError(err).Error("Failed to create Calico release")
os.Exit(1)
}
return
}
if publish {
configureLogging("release-publish.log")
err := r.PublishRelease()
if err != nil {
logrus.WithError(err).Error("Failed to publish Calico release")
os.Exit(1)
}
return
}
if newBranch {
configureLogging("cut-release-branch.log")
err := r.NewBranch()
if err != nil {
logrus.WithError(err).Error("Failed to create new release branch")
os.Exit(1)
}
return
}
logrus.Fatalf("No command specified")
}
func configureLogging(filename string) {
// Set up logging to both stdout as well as a file.
writers := []io.Writer{os.Stdout, &lumberjack.Logger{
Filename: filename,
MaxSize: 100,
MaxAge: 30,
MaxBackups: 10,
}}
logrus.SetOutput(io.MultiWriter(writers...))
}