add some cmdline args
This commit is contained in:
parent
0f48d99b43
commit
0c8311467b
6
Makefile
6
Makefile
|
@ -3,6 +3,12 @@ VERSION = $(shell git describe --tags)
|
|||
all: build
|
||||
./guireleaser
|
||||
|
||||
single: build
|
||||
./guireleaser go.wit.com/apps/go-clone --increment --release --reason "testing guireleaser" --dry-run
|
||||
|
||||
single-really-do-it: build
|
||||
./guireleaser go.wit.com/apps/go-clone --increment --release --reason "testing guireleaser"
|
||||
|
||||
stderr: build
|
||||
echo "writing to /tmp/guireleaser.stderr"
|
||||
./guireleaser >/tmp/guireleaser.stderr 2>&1
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package main
|
||||
|
||||
/*
|
||||
this parses the command line arguements
|
||||
|
||||
this enables command line options from other packages like 'gui' and 'log'
|
||||
*/
|
||||
|
||||
type args struct {
|
||||
Repo string `arg:"positional" help:"go import path"`
|
||||
Increment bool `arg:"--increment" help:"auto increment"`
|
||||
Release bool `arg:"--release" help:"do a release an exit"`
|
||||
DryRun bool `arg:"--dry-run" help:"don't actually do the release"`
|
||||
Reason string `arg:"--reason" help:"tag message"`
|
||||
}
|
||||
|
||||
func (a args) Description() string {
|
||||
return `
|
||||
Example usage:
|
||||
guireleaser go.wit.com/apps/go-clone --increment --release --dry-run --reason "blerg"
|
||||
|
||||
This will pull down the go sources and
|
||||
the repositories in the go.sum file using git clone`
|
||||
}
|
||||
|
||||
func (args) Version() string {
|
||||
return "go-clone " + VERSION
|
||||
}
|
|
@ -186,7 +186,7 @@ func globalDisplayOptions(box *gui.Node) {
|
|||
repo.Status.IncrementMinorVersion("trying minor")
|
||||
}
|
||||
})
|
||||
grid.NewButton("ncrement changed repos", func() {
|
||||
grid.NewButton("increment changed repos", func() {
|
||||
me.Disable()
|
||||
for _, repo := range me.repos.View.AllRepos() {
|
||||
if whitelist(repo.GoPath()) {
|
||||
|
|
69
main.go
69
main.go
|
@ -4,16 +4,22 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/alexflint/go-arg"
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gui/repolist"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
var VERSION string
|
||||
var myargs args
|
||||
|
||||
func main() {
|
||||
me = new(autoType)
|
||||
|
||||
// parse the command line
|
||||
arg.MustParse(&myargs)
|
||||
|
||||
// save the ENV var here
|
||||
me.releaseReasonS = os.Getenv("GUIRELEASE_REASON")
|
||||
|
||||
|
@ -87,6 +93,9 @@ func main() {
|
|||
// TODO: should not really be necessary directly after init()
|
||||
me.repos.View.ScanRepositories()
|
||||
|
||||
// the repo from the command line
|
||||
var myrepo *repolist.RepoRow
|
||||
|
||||
// find myself. the guireleaser directory is used as a working scratchpad
|
||||
// for running go commands that can mess up the go.* files
|
||||
for _, repo := range me.repos.View.AllRepos() {
|
||||
|
@ -95,6 +104,66 @@ func main() {
|
|||
me.release.guireleaser = repo
|
||||
}
|
||||
}
|
||||
if repo.GoPath() == myargs.Repo {
|
||||
myrepo = repo
|
||||
}
|
||||
}
|
||||
|
||||
if myargs.Repo != "" {
|
||||
me.mainWindow.Hide()
|
||||
if myrepo == nil {
|
||||
log.Info("could not find", myargs.Repo)
|
||||
os.Exit(0)
|
||||
}
|
||||
log.Info("only going to do repo:", myrepo.GoPath())
|
||||
tmp := myargs.Reason
|
||||
if tmp == "" {
|
||||
tmp = os.Getenv("GUIRELEASE_REASON")
|
||||
}
|
||||
if tmp == "" {
|
||||
tmp = "made by guireleaser"
|
||||
}
|
||||
|
||||
// increment all the versions
|
||||
for _, repo := range me.repos.View.AllRepos() {
|
||||
if whitelist(repo.GoPath()) {
|
||||
continue
|
||||
}
|
||||
if repo.ReadOnly() {
|
||||
continue
|
||||
}
|
||||
lasttag := repo.Status.LastTag()
|
||||
if repo.Status.GetCurrentVersion() == lasttag {
|
||||
log.Info("skipping unchanged repo", repo.Status.GoPath())
|
||||
repo.Status.SetTargetVersion(lasttag)
|
||||
continue
|
||||
}
|
||||
repo.Status.IncrementRevisionVersion("go-clone")
|
||||
}
|
||||
// rescan all the repos
|
||||
me.repos.View.ScanRepositories()
|
||||
|
||||
|
||||
myrepo.Status.MakeRedomod()
|
||||
myrepo.Status.IncrementRevisionVersion(tmp)
|
||||
_, err := me.repos.View.CheckValidGoSum(myrepo)
|
||||
if err != nil {
|
||||
log.Info("go mod tidy not ok", err)
|
||||
return
|
||||
}
|
||||
if !checkValidGoSum(myrepo) {
|
||||
log.Info("go.sum checks failed")
|
||||
os.Exit(0)
|
||||
}
|
||||
setCurrentRepo(myrepo, "should be good to release", "pretty sure")
|
||||
log.Info("DO THE RELEASE HERE")
|
||||
log.Info("going to release", myrepo.GoPath(), "as version", myrepo.Status.GetTargetVersion())
|
||||
if myargs.DryRun {
|
||||
log.Info("--dry-run == true")
|
||||
} else {
|
||||
doRelease()
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if me.release.guireleaser == nil {
|
||||
|
|
Loading…
Reference in New Issue