mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Automate the Hugo release process
This commit adds a work flow aroung GoReleaser to get the Hugo release process automated and more uniform: * It can be run fully automated or in two steps to allow for manual edits of the relase notes. * It supports both patch and full releases. * It fetches author, issue, repo info. etc. for the release notes from GitHub. * The file names produced are mainly the same as before, but we no use tar.gz as archive for all Unix versions. * There isn't a fully automated CI setup in place yet, but the release tag is marked in the commit message with "[ci deploy]" Fixes #3358
This commit is contained in:
@@ -286,7 +286,7 @@ func InitLoggers() {
|
||||
// plenty of time to fix their templates.
|
||||
func Deprecated(object, item, alternative string, err bool) {
|
||||
if err {
|
||||
DistinctErrorLog.Printf("%s's %s is deprecated and will be removed in Hugo %s. %s.", object, item, NextHugoReleaseVersion(), alternative)
|
||||
DistinctErrorLog.Printf("%s's %s is deprecated and will be removed in Hugo %s. %s.", object, item, CurrentHugoVersion.Next().ReleaseVersion(), alternative)
|
||||
|
||||
} else {
|
||||
// Make sure the users see this while avoiding build breakage. This will not lead to an os.Exit(-1)
|
||||
|
@@ -20,35 +20,51 @@ import (
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
// HugoVersionNumber represents the current build version.
|
||||
// This should be the only one
|
||||
const (
|
||||
// HugoVersion represents the Hugo build version.
|
||||
type HugoVersion struct {
|
||||
// Major and minor version.
|
||||
HugoVersionNumber = 0.21
|
||||
Number float32
|
||||
|
||||
// Increment this for bug releases
|
||||
HugoPatchVersion = 0
|
||||
)
|
||||
PatchLevel int
|
||||
|
||||
// HugoVersionSuffix is the suffix used in the Hugo version string.
|
||||
// It will be blank for release versions.
|
||||
const HugoVersionSuffix = "-DEV" // use this when not doing a release
|
||||
//const HugoVersionSuffix = "" // use this line when doing a release
|
||||
|
||||
// HugoVersion returns the current Hugo version. It will include
|
||||
// a suffix, typically '-DEV', if it's development version.
|
||||
func HugoVersion() string {
|
||||
return hugoVersion(HugoVersionNumber, HugoPatchVersion, HugoVersionSuffix)
|
||||
// HugoVersionSuffix is the suffix used in the Hugo version string.
|
||||
// It will be blank for release versions.
|
||||
Suffix string
|
||||
}
|
||||
|
||||
// HugoReleaseVersion is same as HugoVersion, but no suffix.
|
||||
func HugoReleaseVersion() string {
|
||||
return hugoVersionNoSuffix(HugoVersionNumber, HugoPatchVersion)
|
||||
func (v HugoVersion) String() string {
|
||||
return hugoVersion(v.Number, v.PatchLevel, v.Suffix)
|
||||
}
|
||||
|
||||
// NextHugoReleaseVersion returns the next Hugo release version.
|
||||
func NextHugoReleaseVersion() string {
|
||||
return hugoVersionNoSuffix(HugoVersionNumber+0.01, 0)
|
||||
// ReleaseVersion represents the release version.
|
||||
func (v HugoVersion) ReleaseVersion() HugoVersion {
|
||||
v.Suffix = ""
|
||||
return v
|
||||
}
|
||||
|
||||
// Next returns the next Hugo release version.
|
||||
func (v HugoVersion) Next() HugoVersion {
|
||||
return HugoVersion{Number: v.Number + 0.01}
|
||||
}
|
||||
|
||||
// Pre returns the previous Hugo release version.
|
||||
func (v HugoVersion) Prev() HugoVersion {
|
||||
return HugoVersion{Number: v.Number - 0.01}
|
||||
}
|
||||
|
||||
// NextPatchLevel returns the next patch/bugfix Hugo version.
|
||||
// This will be a patch increment on the previous Hugo version.
|
||||
func (v HugoVersion) NextPatchLevel(level int) HugoVersion {
|
||||
return HugoVersion{Number: v.Number - 0.01, PatchLevel: level}
|
||||
}
|
||||
|
||||
// CurrentHugoVersion represents the current build version.
|
||||
// This should be the only one.
|
||||
var CurrentHugoVersion = HugoVersion{
|
||||
Number: 0.21,
|
||||
PatchLevel: 0,
|
||||
Suffix: "-DEV",
|
||||
}
|
||||
|
||||
func hugoVersion(version float32, patchVersion int, suffix string) string {
|
||||
@@ -58,19 +74,12 @@ func hugoVersion(version float32, patchVersion int, suffix string) string {
|
||||
return fmt.Sprintf("%.2f%s", version, suffix)
|
||||
}
|
||||
|
||||
func hugoVersionNoSuffix(version float32, patchVersion int) string {
|
||||
if patchVersion > 0 {
|
||||
return fmt.Sprintf("%.2f.%d", version, patchVersion)
|
||||
}
|
||||
return fmt.Sprintf("%.2f", version)
|
||||
}
|
||||
|
||||
// CompareVersion compares the given version string or number against the
|
||||
// running Hugo version.
|
||||
// It returns -1 if the given version is less than, 0 if equal and 1 if greater than
|
||||
// the running version.
|
||||
func CompareVersion(version interface{}) int {
|
||||
return compareVersions(HugoVersionNumber, HugoPatchVersion, version)
|
||||
return compareVersions(CurrentHugoVersion.Number, CurrentHugoVersion.PatchLevel, version)
|
||||
}
|
||||
|
||||
func compareVersions(inVersion float32, inPatchVersion int, in interface{}) int {
|
||||
|
@@ -22,10 +22,14 @@ import (
|
||||
|
||||
func TestHugoVersion(t *testing.T) {
|
||||
assert.Equal(t, "0.15-DEV", hugoVersion(0.15, 0, "-DEV"))
|
||||
assert.Equal(t, "0.17", hugoVersionNoSuffix(0.16+0.01, 0))
|
||||
assert.Equal(t, "0.20", hugoVersionNoSuffix(0.20, 0))
|
||||
assert.Equal(t, "0.15.2-DEV", hugoVersion(0.15, 2, "-DEV"))
|
||||
assert.Equal(t, "0.17.3", hugoVersionNoSuffix(0.16+0.01, 3))
|
||||
|
||||
v := HugoVersion{Number: 0.21, PatchLevel: 0, Suffix: "-DEV"}
|
||||
|
||||
require.Equal(t, v.ReleaseVersion().String(), "0.21")
|
||||
require.Equal(t, "0.21-DEV", v.String())
|
||||
require.Equal(t, "0.22", v.Next().String())
|
||||
require.Equal(t, "0.20.3", v.NextPatchLevel(3).String())
|
||||
}
|
||||
|
||||
func TestCompareVersions(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user