Skip to content

Commit

Permalink
Add bump strategies to establish a new development/pre-release version
Browse files Browse the repository at this point in the history
  • Loading branch information
ptgoetz committed Nov 21, 2024
1 parent 2a0194d commit 474d3e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
6 changes: 3 additions & 3 deletions internal/versionbump.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ func (vb *VersionBump) Show(versionStr string) error {
`%s ─┬─ major ─ %s
%s├─ minor ─ %s
%s├─ patch ─ %s
%s├─ pre-new-major ─ %s
%s├─ pre-new-minor ─ %s
%s├─ pre-new-patch ─ %s
%s├─ new-pre-major ─ %s
%s├─ new-pre-minor ─ %s
%s├─ new-pre-patch ─ %s
%s├─ pre ─ %s
%s├─ pre-major ─ %s
%s├─ pre-minor ─ %s
Expand Down
18 changes: 11 additions & 7 deletions pkg/semver/semver.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ const (
PreReleaseMinor BumpStrategy = "pre-minor"
PreReleasePatch BumpStrategy = "pre-patch"
PreReleaseBuild BumpStrategy = "pre-build"
PreReleaseNewMajor BumpStrategy = "pre-new-major"
PreReleaseNewMinor BumpStrategy = "pre-new-minor"
PreReleaseNewPatch BumpStrategy = "pre-new-patch"
PreReleaseNewMajor BumpStrategy = "new-pre-major"
PreReleaseNewMinor BumpStrategy = "new-pre-minor"
PreReleaseNewPatch BumpStrategy = "new-pre-patch"
)

func (b BumpStrategy) String() string {
return string(b)
}

func versionPartInt(part BumpStrategy) int {
switch part {
case Major:
Expand Down Expand Up @@ -106,9 +110,9 @@ func (v *SemanticVersion) String() string {
return version
}

// Bump returns a new SemanticVersion instance after incrementing the specified part.
// If the part is a pre-release part, `preReleaseLabels` must be provided. If the part is a build version part,
// `buildLabel` must be provided. If the part is a root version part, preReleaseLabels and buildLabel are ignored.
// Bump returns a new SemanticVersion instance after applying the specified BumpStrategy.
// If the strategy is a pre-release strategy, `preReleaseLabels` must be provided. If the strategy is a build strategy,
// `buildLabel` must be provided. If the strategy is a root version strategy, preReleaseLabels and buildLabel are ignored.
func (v *SemanticVersion) Bump(strategy BumpStrategy, preReleaseLabels []string, buildLabel string) (*SemanticVersion, error) {
var version *Version
var preReleaseVersion *PreReleaseVersion
Expand Down Expand Up @@ -263,7 +267,7 @@ func ValidatePreReleaseLabels(preReleaseLabels []string) bool {
return true
}

// ValidateBuildLabel checks if the provided pre-release labels are valid
// ValidateBuildLabel checks if the provided build label is valid
func ValidateBuildLabel(buildLabel string) bool {
return utils.IsAllAlphanumeric(buildLabel)
}
Expand Down

0 comments on commit 474d3e9

Please sign in to comment.