summaryrefslogtreecommitdiff
path: root/doPublish.go
blob: 8624e00b496d391f490944862f8ca5cf54e05245 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// 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/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 == "" {
			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.RunRealtimeError(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)
		}
	}
	// todo: os.Stat() file
	time.Sleep(time.Second)
	me.forge.Repos.Load()

	if err := doInstall(); err != nil {
		log.Info("doInstall() failed", err)
		me.sh.BadExit("merge failed", nil)
	}

	cmd = []string{"guireleaser", "--gui", "andlabs", "--auto-run", "quick"}
	if argv.Publish.Gomod {
		cmd = append(cmd, "--keep-gomod")
	}
	if _, err := shell.RunRealtimeError(cmd); err != nil {
		log.Info("releaser failed", err)
		me.sh.BadExit("publishing failed", nil)
	}

	me.sh.GoodExit("PUBLISH WORKED")
	return nil
}