From e66a33d369f2a5aee472fdcd82efefbb9efde8d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 28 Jan 2026 16:54:57 +0100 Subject: [PATCH] Revert "release: Support alpha, beta, and RC releases" This reverts commit 663075920ae4e3e4b1a457ad9fef33d4eac9855d. Closes #14448 --- commands/release.go | 4 +--- common/version/version.go | 7 ------ releaser/releaser.go | 47 +++++++++++++++++---------------------- 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/commands/release.go b/commands/release.go index ae97cadc7..059f04eb8 100644 --- a/commands/release.go +++ b/commands/release.go @@ -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)) }, } diff --git a/common/version/version.go b/common/version/version.go index 34ed9bfd1..eae43e8c1 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -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 == "" } diff --git a/releaser/releaser.go b/releaser/releaser.go index 6e3fd3afa..74770dfbd 100644 --- a/releaser/releaser.go +++ b/releaser/releaser.go @@ -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 -- 2.39.5