diff options
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | argv.go | 3 | ||||
| -rw-r--r-- | doPublish.go | 58 | ||||
| -rw-r--r-- | exit.go | 2 | ||||
| -rw-r--r-- | main.go | 11 | ||||
| -rw-r--r-- | structs.go | 9 |
6 files changed, 80 insertions, 6 deletions
@@ -49,3 +49,6 @@ apt-update: -o Dir::Etc::sourcelist=/etc/apt/sources.list.d/wit.list \ -o Dir::Etc::sourceparts=/dev/null \ -o APT::Get::List-Cleanup=0 + +publish: + GUIRELEASE_REASON="test publish" wit publish @@ -28,6 +28,7 @@ type args struct { Rdate *EmptyCmd `arg:"subcommand:rdate" help:"standard rdate"` Zoo *EmptyCmd `arg:"subcommand:zoo" help:"WIT Private Cloud info"` Upgrade *UpgradeCmd `arg:"subcommand:upgrade" help:"apt upgrade packages installed from mirrors.wit.com"` + Publish *EmptyCmd `arg:"subcommand:publish" help:"publish packages"` RepoMap string `arg:"--repomap" help:"location of the repomap"` DryRun bool `arg:"--dry-run" help:"only show what would be packaged"` Install bool `arg:"--install" help:"go install the binaries first"` @@ -118,7 +119,7 @@ func (args) Appname() string { } func (a args) DoAutoComplete(pb *prep.Auto) { - base := []string{"--version", "build", "upgrade", "git", "--force"} + base := []string{"--version", "build", "upgrade", "git", "publish", "--force"} if _, err := fhelp.CheckCmd("zood"); err == nil { base = append(base, "zoo") } diff --git a/doPublish.go b/doPublish.go new file mode 100644 index 0000000..ed38d5b --- /dev/null +++ b/doPublish.go @@ -0,0 +1,58 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +import ( + "fmt" + "os" + + "go.wit.com/lib/fhelp" + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + +func doPublish() error { + initForge() + + saferepo := me.forge.Repos.FindByNamespace("go.wit.com/lib/xgb") // safe to run things here + if saferepo == nil { + return log.Errorf("need a safe place to run GO commands from") + } + os.Chdir(saferepo.FullPath) + + if os.Getenv("GUIRELEASE_REASON") == "" { + reason := fhelp.InputFromUser("set tag message:") + if reason == "" { + me.sh.BadExit("merge failed", fmt.Errorf("GUIRELEASE_REASON was blank")) + } + os.Setenv("GUIRELEASE_REASON", reason) + } + + var cmd []string + + cmd = []string{"forge", "merge", "--all"} + if _, err := shell.RunVerbose(cmd); err != nil { + me.sh.BadExit("merge failed", nil) + } + + cmd = []string{"forge", "merge", "check"} + if _, err := shell.RunRealtimeError(cmd); err != nil { + if _, err := shell.RunVerbose(cmd); err != nil { + me.sh.BadExit("merge failed", nil) + } + } + + if err := doInstall(); err != nil { + log.Info("doInstall() failed", err) + me.sh.BadExit("merge failed", nil) + } + + cmd = []string{"guireleaser", "--gui", "andlabs", "quick"} + if _, err := shell.RunRealtimeError(cmd); err != nil { + me.sh.BadExit("merge failed", nil) + } + + log.Info("PUBLISH WORKED") + return nil +} @@ -52,6 +52,6 @@ func okExit(thing string) { } func badExit(err error) { - log.Info("wit failed: ", err) + me.sh.BadExit("wit failed: ", err) os.Exit(-1) } @@ -11,6 +11,7 @@ import ( "path/filepath" "unicode" + "go.wit.com/dev/davecgh/spew" "go.wit.com/log" ) @@ -62,6 +63,13 @@ func main() { doUpgrade() } + if argv.Publish != nil { + if err := doPublish(); err != nil { + badExit(err) + } + okExit("") + } + if argv.Zoo != nil { if areSuperuser() { exitOnErrorRealtime([]string{"journalctl", "-n", "100", "-f", "_SYSTEMD_UNIT=zood.service"}) @@ -140,7 +148,8 @@ func dumpDebug() { return } - fmt.Println("Go Version:", bi.GoVersion) + log.Infof("%s built with Go version: %s\n", exePath, bi.GoVersion) + spew.Dump(bi) for _, dep := range bi.Deps { fmt.Printf("Dependency: %s %s\n", dep.Path, dep.Version) } @@ -6,6 +6,7 @@ package main import ( "os" "sync" + "time" "go.wit.com/lib/gui/prep" "go.wit.com/lib/protobuf/forgepb" @@ -17,7 +18,8 @@ var me *mainType // this app's variables type mainType struct { once sync.Once // one-time initialized data - auto *prep.Auto // more experiments for bash handling + start time.Time // what the app starts (used for timing automated runs) + sh *prep.Auto // more experiments for bash handling forge *forgepb.Forge // your customized repo preferences and settings machine *zoopb.Machine // your customized repo preferences and settings homedir string // where the user homedir is @@ -39,7 +41,8 @@ func initMachine() { func initMain() { // autocomplete must be processed before there is anything sent to STDOUT or STDERR - me.auto = prep.Bash3(&argv) // add support for bash autocomplete with go-arg + me.sh = prep.Bash3(&argv) // add support for bash autocomplete with go-arg me.homedir, _ = os.UserHomeDir() // store shortcut here todo: add better logic - dumpDebug() // tinkering + me.start = time.Now() + dumpDebug() // tinkering } |
