]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Revert "release: Support alpha, beta, and RC releases"
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 28 Jan 2026 15:54:57 +0000 (16:54 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 28 Jan 2026 15:54:57 +0000 (16:54 +0100)
This reverts commit 663075920ae4e3e4b1a457ad9fef33d4eac9855d.

Closes #14448

commands/release.go
common/version/version.go
releaser/releaser.go

index ae97cadc777d643d8683380e63e9f7154a604b6f..059f04eb8bd9aef68ac4d26bbbdba6f0e65958a9 100644 (file)
@@ -28,14 +28,13 @@ func newReleaseCommand() simplecobra.Commander {
                step     int
                skipPush bool
                try      bool
-               version  string
        )
 
        return &simpleCommand{
                name:  "release",
                short: "Release a new version of Hugo",
                run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error {
-                       rel, err := releaser.New(skipPush, try, step, version)
+                       rel, err := releaser.New(skipPush, try, step)
                        if err != nil {
                                return err
                        }
@@ -48,7 +47,6 @@ func newReleaseCommand() simplecobra.Commander {
                        cmd.PersistentFlags().BoolVarP(&skipPush, "skip-push", "", false, "skip pushing to remote")
                        cmd.PersistentFlags().BoolVarP(&try, "try", "", false, "no changes")
                        cmd.PersistentFlags().IntVarP(&step, "step", "", 0, "step to run (1: set new version 2: prepare next dev version)")
-                       cmd.PersistentFlags().StringVarP(&version, "version", "", "", "version to release (derived from branch name if not set)")
                        _ = cmd.RegisterFlagCompletionFunc("step", cobra.FixedCompletions([]string{"1", "2"}, cobra.ShellCompDirectiveNoFileComp))
                },
        }
index 34ed9bfd1a4992485ebffe22feb2fee020efefe3..eae43e8c1835ef55124f02be916dd04914365bd7 100644 (file)
@@ -47,13 +47,6 @@ var (
        _ compare.Comparer = (*VersionString)(nil)
 )
 
-// IsAlphaBetaOrRC returns whether this version is an alpha, beta, or release candidate.
-func (v Version) IsAlphaBetaOrRC() bool {
-       s := strings.ToLower(v.Suffix)
-       // e.g. "alpha.1", "beta.2", "rc.3"
-       return strings.Contains(s, "alpha.") || strings.Contains(s, "beta.") || strings.Contains(s, "rc.")
-}
-
 func (v Version) IsZero() bool {
        return v.Major == 0 && v.Minor == 0 && v.PatchLevel == 0 && v.Suffix == ""
 }
index 6e3fd3afa484dd7e477f6cabad8f60822a27d09c..74770dfbd99482b8adb8e27d577fa3966b236b13 100644 (file)
@@ -30,32 +30,28 @@ import (
 const commitPrefix = "releaser:"
 
 // New initializes a ReleaseHandler.
-// Note that version is only used for testig. In CI we derive the version from the branch name.
-func New(skipPush, try bool, step int, version string) (*ReleaseHandler, error) {
+func New(skipPush, try bool, step int) (*ReleaseHandler, error) {
        if step < 1 || step > 2 {
                return nil, fmt.Errorf("step must be 1 or 2")
        }
 
-       if version == "" {
-               prefix := "release-"
-               branch, err := git("rev-parse", "--abbrev-ref", "HEAD")
-               if err != nil {
-                       return nil, err
-               }
-               branch = strings.TrimSpace(branch)
-
-               if !strings.HasPrefix(branch, prefix) {
-                       return nil, fmt.Errorf("branch %q is not a release branch", branch)
-               }
+       prefix := "release-"
+       branch, err := git("rev-parse", "--abbrev-ref", "HEAD")
+       if err != nil {
+               return nil, err
+       }
+       branch = strings.TrimSpace(branch)
 
-               version = strings.TrimPrefix(branch, prefix)
+       if !strings.HasPrefix(branch, prefix) {
+               return nil, fmt.Errorf("branch %q is not a release branch", branch)
        }
 
+       version := strings.TrimPrefix(branch, prefix)
        version = strings.TrimPrefix(version, "v")
 
-       logf("Version: v%s\n", version)
+       logf("Branch: %s|Version: v%s\n", branch, version)
 
-       rh := &ReleaseHandler{version: version, skipPush: skipPush, try: try, step: step}
+       rh := &ReleaseHandler{branchVersion: version, skipPush: skipPush, try: try, step: step}
 
        if try {
                rh.git = func(args ...string) (string, error) {
@@ -74,7 +70,7 @@ func New(skipPush, try bool, step int, version string) (*ReleaseHandler, error)
 // go run -tags release main.go release --skip-publish --try -r 0.90.0
 // Or a variation of the above -- the skip-publish flag makes sure that any changes are performed to the local Git only.
 type ReleaseHandler struct {
-       version string
+       branchVersion string
 
        // 1 or 2.
        step int
@@ -93,8 +89,8 @@ func (r *ReleaseHandler) Run() error {
        newVersion, finalVersion := r.calculateVersions()
        version := newVersion.String()
        tag := "v" + version
-
-       logf("New version %q (prerelease: %t), final version %q\n", newVersion, newVersion.IsAlphaBetaOrRC(), finalVersion)
+       mainVersion := newVersion
+       mainVersion.PatchLevel = 0
 
        r.gitPull()
 
@@ -171,15 +167,14 @@ func (r *ReleaseHandler) bumpVersions(ver version.Version) error {
 }
 
 func (r ReleaseHandler) calculateVersions() (version.Version, version.Version) {
-       newVersion := version.MustParseVersion(r.version)
-       var finalVersion version.Version
-       if newVersion.IsAlphaBetaOrRC() {
-               finalVersion = newVersion
-       } else {
-               finalVersion = newVersion.Next()
+       newVersion := version.MustParseVersion(r.branchVersion)
+       finalVersion := newVersion.Next()
+       finalVersion.PatchLevel = 0
+
+       if newVersion.Suffix != "-test" {
+               newVersion.Suffix = ""
        }
 
-       finalVersion.PatchLevel = 0
        finalVersion.Suffix = "-DEV"
 
        return newVersion, finalVersion