summaryrefslogtreecommitdiff
path: root/doPublish.go
blob: efa8af2dc376b3550f4d39da366d1701bfbfb848 (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
68
69
70
71
72
73
74
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0

package main

import (
	"errors"
	"fmt"

	"go.wit.com/lib/env"
	"go.wit.com/lib/protobuf/argvpb"
)

func doPublish() error {
	initForge()

	// publish := me.forge.RunOnReposNewDumb(me.forge.Repos, rePrepareReleaseNew) // doesn't use Rill()
	publish := me.forge.RunOnReposNew(me.forge.Repos, rePrepareReleaseNew)
	if publish != nil {
		publish = publish.SortActual()
		footer := publish.PrintPublishNewTB()
		fmt.Printf("publish.len(%d) PrintPublishTable() footer: %s\n", publish.Len(), footer)
	}
	if !env.True("--doit") {
		return errors.New("run with --doit to actually try to publish")
	}
	// me.forge.RillFuncError(rillPurge)

	/*
		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")
		}
	*/

	argvpb.GoodExit("PUBLISH WORKED")
	return nil
}