Skip to content

Commit cf431d6

Browse files
committed
fix(release): handle version increase resets
handle the reset of the semver to 0 during semver version increases and additionally handle the beta tag increment with the same ci: additionally update the ci scripts to dogfooding latest
1 parent f5fd808 commit cf431d6

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

.github/workflows/create-binaries-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Generate Change Log
2121
id: generate_log
2222
run: |
23-
curl -L https://github.com/barelyhuman/commitlog/releases/download/v0.0.6/commitlog-linux-amd64.tar.gz -o clog.tar.gz
23+
curl -L https://github.com/barelyhuman/commitlog/releases/download/v0.0.7-dev.1/commitlog-linux-amd64.tar.gz -o clog.tar.gz
2424
tar -xvzf clog.tar.gz
2525
chmod +x commitlog
2626
./commitlog . > CHANGELOG.txt

.github/workflows/create-binaries.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Generate Change Log
2121
id: generate_log
2222
run: |
23-
curl -L https://github.com/barelyhuman/commitlog/releases/download/v0.0.6/commitlog-linux-amd64.tar.gz -o clog.tar.gz
23+
curl -L https://github.com/barelyhuman/commitlog/releases/download/v0.0.7-dev.1/commitlog-linux-amd64.tar.gz -o clog.tar.gz
2424
tar -xvzf clog.tar.gz
2525
chmod +x commitlog
2626
./commitlog . > CHANGELOG.txt

cmd/release/release.go

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ var betaSuffixPrompt = &survey.Input{
3838

3939
// TagVersion - struct holding the broken down tag
4040
type TagVersion struct {
41-
major string
42-
minor string
43-
patch string
44-
beta string
45-
isBeta bool
41+
major string
42+
minor string
43+
patch string
44+
beta string
4645
}
4746

4847
// Install - add flags and other options
@@ -99,14 +98,20 @@ func needsQuestionnaire(args []string) bool {
9998

10099
switch semver {
101100
case "major":
102-
*major = true
103-
break
101+
{
102+
*major = true
103+
break
104+
}
104105
case "minor":
105-
*minor = true
106-
break
106+
{
107+
*minor = true
108+
break
109+
}
107110
case "patch":
108-
*patch = true
109-
break
111+
{
112+
*patch = true
113+
break
114+
}
110115
}
111116
}
112117

@@ -116,6 +121,7 @@ func needsQuestionnaire(args []string) bool {
116121
func createRelease(tagString string, increaseMajor bool, increaseMinor bool, increasePatch bool, betaSuffix string, isBeta bool) {
117122
version, hasV := breakTag(tagString)
118123
releaseTagString := ""
124+
isIncreasedSemver := false
119125

120126
majorAsInt, err := strconv.ParseInt(version.major, 10, 32)
121127
if err != nil {
@@ -140,20 +146,29 @@ func createRelease(tagString string, increaseMajor bool, increaseMinor bool, inc
140146

141147
if increaseMajor {
142148
majorAsInt++
149+
minorAsInt = 0
150+
patchAsInt = 0
151+
isIncreasedSemver = true
143152
}
144153

145154
if increaseMinor {
146155
minorAsInt++
156+
patchAsInt = 0
157+
isIncreasedSemver = true
147158
}
148159

149160
if increasePatch {
150161
patchAsInt++
162+
isIncreasedSemver = true
151163
}
152164

153165
releaseTagString += fmt.Sprintf("%d.%d.%d", majorAsInt, minorAsInt, patchAsInt)
154166

155167
if isBeta {
156168
betaAsInt++
169+
if isIncreasedSemver {
170+
betaAsInt = 0
171+
}
157172
releaseTagString += fmt.Sprintf("-%s.%d", betaSuffix, betaAsInt)
158173
}
159174

0 commit comments

Comments
 (0)