summaryrefslogtreecommitdiff
path: root/prepareRelease.go
blob: bd8d4336c47fb5a0151bdf0290af9920e9104654 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package main

import (
	"os"

	"go.wit.com/log"
)

func makePrepareRelease() {
	me.Disable()
	me.release.box.Disable()
	defer me.Enable()

	if setAllBranchesToMaster() {
		// if it succeeds, disable this button
		me.setBranchesToMasterB.Disable()
		me.release.box.Enable()
		PrintReleaseReport("", "")
	} else {
		log.Info("setAllBranchesToMaster() failed")
	}

	// first reset all the target versions back to the current version
	// incase there was a partial release process running that
	// did not finish
	loop := me.repos.View.ReposSortByName()
	for loop.Scan() {
		repo := loop.Repo()

		// find the gitpb.Repo
		check := me.forge.Repos.FindByGoPath(repo.GoPath())
		if check == nil {
			log.Info("boo, you didn't git clone", repo.GoPath())
			os.Exit(-1)
		}

		// set the target version to the current master version
		curver := repo.Status.GetMasterVersion()
		check.SetTargetVersion(curver)
	}

	// on startup, run fixGoDeps() on every go.sum that didn't match
	if argv.Fix {
		loop = me.repos.View.ReposSortByName()
		for loop.Scan() {
			repo := loop.Repo()
			// find the gitpb.Repo
			check := me.forge.Repos.FindByGoPath(repo.GoPath())
			if check == nil {
				log.Info("boo, you didn't git clone", repo.GoPath())
				os.Exit(-1)
			}
			if !me.forge.FinalGoDepsCheckOk(check) {
				fixGodeps(check)
			}
		}
	}

	// now figure out what to release and increment the version
	loop = me.repos.View.ReposSortByName()
	for loop.Scan() {
		repo := loop.Repo()
		// find the gitpb.Repo
		check := me.forge.Repos.FindByGoPath(repo.GoPath())
		if check == nil {
			log.Info("boo, you didn't git clone", repo.GoPath())
			os.Exit(-1)
		}

		// if check.GetGoPath() == "go.wit.com/dev/alexflint/arg" {
		if check.GetGoPath() == "go.wit.com/gui" {
			log.Info("arg", check.GetGoPath(), check.GetMasterVersion(), check.GoPrimitive)
			if me.forge.FinalGoDepsCheckOk(check) {
				log.Info("arg final check true", check.GetGoPath())
			} else {
				log.Info("arg final check false", check.GetGoPath())
				// os.Exit(-1)
			}
			// see if there is a new version
			master := repo.Status.GetMasterVersion()
			lastTag := repo.Status.LastTag()
			log.Info("arg ", master, lastTag)
			// os.Exit(-1)
		}
		// check if the package dependancies changed, if so, re-publish
		if !check.GoPrimitive {
			if me.forge.FinalGoDepsCheckOk(check) {
				log.Printf("go.sum is perfect! %s\n", check.GetGoPath())
			} else {
				log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath())
				repo.Status.IncrementRevisionVersion("godeps changed")
				target := repo.Status.GetTargetVersion()
				check.SetTargetVersion(target)
			}
		}

		// see if there is a new version
		master := repo.Status.GetMasterVersion()
		lastTag := repo.Status.LastTag()
		if master == lastTag {
			repo.Status.SetTargetVersion(master)
		} else {
			repo.Status.IncrementRevisionVersion("Nov 2024 test")
			target := repo.Status.GetTargetVersion()
			check.SetTargetVersion(target)
		}
		// if check.GetGoPath() == "go.wit.com/dev/alexflint/arg" {
		// if check.GetGoPath() == "go.wit.com/gui" {
		if check.GetGoPath() == "go.wit.com/dev/davecgh/spew" {
			log.Info(repo.StandardReleaseHeader())
			log.Info(me.forge.StandardReleaseHeader(check, repo.State()))
			log.Info("arg", check.GetGoPath(), check.GetMasterVersion(), check.GoPrimitive)
			if me.forge.FinalGoDepsCheckOk(check) {
				log.Info("go.sum is perfect")
			} else {
				log.Info("go.sum check false")
			}
			// see if there is a new version
			master := repo.Status.GetMasterVersion()
			lastTag := repo.Status.LastTag()
			log.Info("arg ", master, lastTag)
			if master != lastTag {
				os.Exit(-1)
			}
		}
	}
	findNext()
}