From 38b1ecab60974813ecf8d64685f2992152b3edf9 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 20 Feb 2024 23:13:26 -0600 Subject: [PATCH] add --release builds --- Makefile | 30 ++++++++++++++++++++++++++++++ addRepo.go | 37 ++++++++++++++++++++++++------------- args.go | 7 ++++--- controlBox.go | 2 +- main.go | 2 ++ stateWindow.go | 30 ++++++++++++++++++++++-------- 6 files changed, 83 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index a62edf5..95801a0 100644 --- a/Makefile +++ b/Makefile @@ -7,9 +7,15 @@ no-gui: build ./go-deb --no-gui --repo go.wit.com/apps/autotypist build: + -mkdir resources -cp ~/go/src/go.wit.com/toolkits/*.so resources/ GO111MODULE="off" go build -v +install: + -mkdir resources + -cp ~/go/src/go.wit.com/toolkits/*.so resources/ + GO111MODULE="off" go install -v + goimports: goimports -w *.go @@ -40,3 +46,27 @@ debian: mirrors: -wit mirrors + +build-all: + go-deb --no-gui --repo go.wit.com/apps/autotypist + go-deb --no-gui --repo go.wit.com/apps/control-panel-digitalocean + go-deb --no-gui --repo go.wit.com/apps/control-panel-vpn + go-deb --no-gui --repo go.wit.com/apps/go-gui-toolkits + go-deb --no-gui --repo go.wit.com/apps/guireleaser + go-deb --no-gui --repo go.wit.com/apps/control-panel-cloudflare + go-deb --no-gui --repo go.wit.com/apps/control-panel-dns + go-deb --no-gui --repo go.wit.com/apps/go-deb + go-deb --no-gui --repo go.wit.com/apps/go.wit.com + go-deb --no-gui --repo go.wit.com/apps/helloworld + +build-releases: + go-deb --release --no-gui --repo go.wit.com/apps/autotypist + go-deb --release --no-gui --repo go.wit.com/apps/control-panel-digitalocean + go-deb --release --no-gui --repo go.wit.com/apps/control-panel-vpn + go-deb --release --no-gui --repo go.wit.com/apps/go-gui-toolkits + go-deb --release --no-gui --repo go.wit.com/apps/guireleaser + go-deb --release --no-gui --repo go.wit.com/apps/control-panel-cloudflare + go-deb --release --no-gui --repo go.wit.com/apps/control-panel-dns + go-deb --release --no-gui --repo go.wit.com/apps/go-deb + go-deb --release --no-gui --repo go.wit.com/apps/go.wit.com + go-deb --release --no-gui --repo go.wit.com/apps/helloworld diff --git a/addRepo.go b/addRepo.go index 4371cd6..f679107 100644 --- a/addRepo.go +++ b/addRepo.go @@ -25,12 +25,12 @@ func (c *controlBox) addRepo(path string) { return } - if repostatus.VerifyLocalGoRepo(path) { - log.Verbose("path actually exists", path) - } else { - log.Warn("repostatus.VerifyLocalGoRepo() failed for for", path) - return - } + // if repostatus.VerifyLocalGoRepo(path) { + // log.Verbose("path actually exists", path) + // } else { + // log.Warn("repostatus.VerifyLocalGoRepo() failed for for", path) + // return + // } c.pathL = gadgets.NewOneLiner(c.grid, "path") c.pathL.SetText(path) @@ -54,10 +54,15 @@ func (c *controlBox) addRepo(path string) { c.tagDate = gadgets.NewOneLiner(c.grid, "git tag Date") c.grid.NextRow() - c.status = repostatus.NewRepoStatusWindow(path) - c.status.SetMainWorkingName("master") - c.status.SetDevelWorkingName("devel") - c.status.SetUserWorkingName("jcarr") + err, repo := repostatus.NewRepoStatusWindow(path) + if err != nil { + log.Info("path did not work", path, err) + return + } + c.status = repo + // c.status.SetMainWorkingName("master") + // c.status.SetDevelWorkingName("devel") + // c.status.SetUserWorkingName("jcarr") c.status.Update() cbname := c.status.GetCurrentBranchName() @@ -71,17 +76,23 @@ func (c *controlBox) addRepo(path string) { c.dirtyL.SetText("false") } + lasttag := c.status.GetLastTagVersion() + if args.Release { + debversion = lasttag + debversion = strings.TrimPrefix(debversion, "v") + c.dirtyL.SetText("false") + } + c.Version.SetText(debversion) - lasttag := c.status.GetLastTagVersion() c.lastTag.SetText(lasttag) c.currentL.SetText(cbname + " " + cbversion) tagDate := c.getDateStamp(lasttag) c.tagDate.SetText(tagDate) - if c.status.Changed() { - log.Warn("should scan here") + if s, ok := c.status.Changed(); ok { + log.Warn("should scan here", s) } return diff --git a/args.go b/args.go index 36d6918..70c34fd 100644 --- a/args.go +++ b/args.go @@ -13,9 +13,10 @@ import ( ) var args struct { - NoGui bool `arg:"--no-gui" help:"don't open the gui, just make the .deb"` - Repo string `arg:"--repo" help:"go get path to the repo"` - PkgDir string `arg:"--pkg-dir" help:"set default directory (~/incoming/)"` + NoGui bool `arg:"--no-gui" help:"don't open the gui, just make the .deb"` + Repo string `arg:"--repo" help:"go get path to the repo"` + PkgDir string `arg:"--pkg-dir" help:"set default directory (~/incoming/)"` + Release bool `arg:"--release" help:"build a release from the last git tag"` } func init() { diff --git a/controlBox.go b/controlBox.go index ad2966e..888163d 100644 --- a/controlBox.go +++ b/controlBox.go @@ -28,7 +28,7 @@ type controlBox struct { dirtyL *gadgets.OneLiner currentL *gadgets.OneLiner buildDate *gadgets.OneLiner - tagDate *gadgets.OneLiner + tagDate *gadgets.OneLiner status *repostatus.RepoStatus } diff --git a/main.go b/main.go index b88749c..c5ab1b1 100644 --- a/main.go +++ b/main.go @@ -36,6 +36,7 @@ func main() { // scan the repo cBox.addRepo(args.Repo) + // look for a 'config' file in the repo if cBox.readControlFile() == nil { log.Warn("scan worked") @@ -50,6 +51,7 @@ func main() { log.Info("build worked") } else { log.Warn("build failed") + os.Exit(-1) } os.Exit(0) } diff --git a/stateWindow.go b/stateWindow.go index 142c8b7..cb03e01 100644 --- a/stateWindow.go +++ b/stateWindow.go @@ -60,14 +60,27 @@ func makebasicWindow() *gadgets.BasicWindow { func (c *controlBox) buildPackage() bool { // TODO: if dirty, set GO111MODULE // also, if last tag != version - if c.status.CheckDirty() { - os.Setenv("GO111MODULE", "off") - } - if shell.Run([]string{"go", "build", "-v", "-x"}) { - log.Warn("build worked") + if args.Release { + os.Unsetenv("GO111MODULE") + path := c.pathL.String() + "@latest" + cmd := []string{"go", "install", "-v", "-x", path} + if shell.Run(cmd) { + log.Warn("build worked") + } else { + log.Warn("build failed") + return false + } } else { - log.Warn("build failed") - return false + + if c.status.CheckDirty() { + os.Setenv("GO111MODULE", "off") + } + if shell.Run([]string{"go", "build", "-v", "-x"}) { + log.Warn("build worked") + } else { + log.Warn("build failed") + return false + } } filename := c.Package.String() @@ -212,7 +225,8 @@ func (c *controlBox) computeControlValues() bool { // TODO: get this from gitea (or gitlab or github, etc) // or from the README.md ? if c.Description.String() == "" { - c.Description.SetText("missing control file") + path := c.pathL.String() + c.Description.SetText("GO binary of " + path) } return true }