// 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" "time" "go.wit.com/lib/fhelp" "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/argvpb" "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") == "" { log.Info("$ENV[GUIRELEASE_REASON] was not set") reason := fhelp.InputFromUser("set tag message:") if reason == "" { argvpb.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.RunRealtimeError(cmd); err != nil { argvpb.BadExit("merge failed", nil) } cmd = []string{"forge", "merge", "check"} if _, err := shell.RunRealtimeError(cmd); err != nil { if _, err := shell.RunVerbose(cmd); err != nil { argvpb.BadExit("merge failed", nil) } } // todo: os.Stat() file time.Sleep(time.Second) me.forge.Repos.Load() if err := doInstall(me.forge.Repos); err != nil { log.Info("doInstall() failed", err) argvpb.BadExit("merge failed", nil) } if os.Getenv("GUIRELEASE_REASON") == "" { os.Setenv("GUIRELEASE_REASON", "automated") } cmd = []string{"guireleaser", "--gui", "andlabs", "--auto-run"} if argv.All { // publish everything. don't be quick about it // updates all go.mod and go.sum files for every repo // that has dependancy changes. todo: only do binaries } else { // only publish packages that have commits cmd = append(cmd, "quick") } if argv.Publish.Gomod { // don't delete the .pb.go and go.* files from the master branch right away cmd = append(cmd, "--keep-gomod") } if _, err := shell.RunRealtimeError(cmd); err != nil { log.Info("releaser failed", err) argvpb.BadExit("publishing failed", nil) } argvpb.GoodExit("PUBLISH WORKED") return nil }