Skip to content

Commit

Permalink
add cli support for release
Browse files Browse the repository at this point in the history
  • Loading branch information
foosinn committed May 5, 2020
1 parent 9f7ff35 commit b3f5e4a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/dronetrigger/main.go
Original file line number Diff line number Diff line change
@@ -6,13 +6,15 @@ import (
"os"

"github.com/bitsbeats/dronetrigger/config"
"github.com/bitsbeats/dronetrigger/core"
"github.com/bitsbeats/dronetrigger/drone"
)

func main() {
log.SetFlags(0)
log.SetOutput(os.Stdout)
branch := flag.String("branch", "", "Git branch to trigger build.")
release := flag.Bool("release", false, "Rebuild last release tag. Mutally exclusive with -branch")
repo := flag.String("repo", "", "Repository to build (i.e. octocat/awesome).")
configFile := flag.String("config", "/etc/dronetrigger.yml", "Configuration file.")
verbose := flag.Bool("v", false, "Verbose output.")
@@ -23,14 +25,24 @@ func main() {
flag.PrintDefaults()
log.Fatal("\nplease specify a repository.")
}
if *release && *branch != "" {
flag.PrintDefaults()
log.Fatal("unable to use -release with -branch")
}

c, err := config.LoadConfig(*configFile)
if err != nil {
log.Fatal(err)
}

d := drone.New(c.Url, c.Token)
build, err := d.RebuildLastBuild(*repo, *branch)

build := (*core.Build)(nil)
if *release {
build, err = d.RebuildLastTag(*repo)
} else {
build, err = d.RebuildLastBuild(*repo, *branch)
}
if err != nil {
log.Fatal(err)
}

0 comments on commit b3f5e4a

Please sign in to comment.