Permalink
Browse files

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
  • Loading branch information...
bep committed Apr 13, 2017
1 parent 9bf5c38 commit 550eba64705725eb54fdb1042e0fb4dbf6f29fd0
View
@@ -14,4 +14,5 @@ vendor/*/
*.bench
coverage*.out
GoBuilds
GoBuilds
dist
View
@@ -36,7 +36,7 @@ in the "man" directory under the current directory.`,
header := &doc.GenManHeader{
Section: "1",
Manual: "Hugo Manual",
Source: fmt.Sprintf("Hugo %s", helpers.HugoVersion()),
Source: fmt.Sprintf("Hugo %s", helpers.CurrentHugoVersion),
}
if !strings.HasSuffix(genmandir, helpers.FilePathSeparator) {
genmandir += helpers.FilePathSeparator
View
@@ -399,7 +399,7 @@ func InitializeConfig(subCmdVs ...*cobra.Command) (*deps.DepsCfg, error) {
if themeVersionMismatch {
cfg.Logger.ERROR.Printf("Current theme does not support Hugo version %s. Minimum version required is %s\n",
helpers.HugoReleaseVersion(), minVersion)
helpers.CurrentHugoVersion.ReleaseVersion(), minVersion)
}
return cfg, nil
View
@@ -0,0 +1,62 @@
// +build release
// Copyright 2017-present The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package commands
import (
"github.com/spf13/cobra"
"github.com/spf13/hugo/releaser"
)
func init() {
HugoCmd.AddCommand(createReleaser().cmd)
}
type releaseCommandeer struct {
cmd *cobra.Command
// Will be zero for main releases.
patchLevel int
skipPublish bool
step int
}
func createReleaser() *releaseCommandeer {
// Note: This is a command only meant for internal use and must be run
// via "go run -tags release main.go release" on the actual code base that is in the release.
r := &releaseCommandeer{
cmd: &cobra.Command{
Use: "release",
Short: "Release a new version of Hugo.",
Hidden: true,
},
}
r.cmd.RunE = func(cmd *cobra.Command, args []string) error {
return r.release()
}
r.cmd.PersistentFlags().IntVarP(&r.patchLevel, "patch", "p", 0, "Patch level, defaults to 0 for main releases")
r.cmd.PersistentFlags().IntVarP(&r.step, "step", "s", -1, "Release step, defaults to -1 for all steps.")
r.cmd.PersistentFlags().BoolVarP(&r.skipPublish, "skip-publish", "", false, "Skip all publishing pipes of the release")
return r
}
func (r *releaseCommandeer) release() error {
return releaser.New(r.patchLevel, r.step, r.skipPublish).Run()
}
View
@@ -44,9 +44,9 @@ func printHugoVersion() {
formatBuildDate() // format the compile time
}
if hugolib.CommitHash == "" {
jww.FEEDBACK.Printf("Hugo Static Site Generator v%s %s/%s BuildDate: %s\n", helpers.HugoVersion(), runtime.GOOS, runtime.GOARCH, hugolib.BuildDate)
jww.FEEDBACK.Printf("Hugo Static Site Generator v%s %s/%s BuildDate: %s\n", helpers.CurrentHugoVersion, runtime.GOOS, runtime.GOARCH, hugolib.BuildDate)
} else {
jww.FEEDBACK.Printf("Hugo Static Site Generator v%s-%s %s/%s BuildDate: %s\n", helpers.HugoVersion(), strings.ToUpper(hugolib.CommitHash), runtime.GOOS, runtime.GOARCH, hugolib.BuildDate)
jww.FEEDBACK.Printf("Hugo Static Site Generator v%s-%s %s/%s BuildDate: %s\n", helpers.CurrentHugoVersion, strings.ToUpper(hugolib.CommitHash), runtime.GOOS, runtime.GOARCH, hugolib.BuildDate)
}
}
View
@@ -45,6 +45,11 @@ pluralizeListTitles = false
identifier = "about"
pre = "<i class='fa fa-heart'></i>"
weight = -110
[[menu.main]]
name = "Release Notes"
url = "/release-notes/"
pre = "<i class='fa fa-newspaper-o'></i>"
weight = -111
[[menu.main]]
name = "Getting Started"
identifier = "getting started"
@@ -0,0 +1,8 @@
---
date: 2017-04-17
aliases:
- /doc/release-notes/
- /meta/release-notes/
title: Release Notes
weight: 10
---
@@ -2,12 +2,8 @@
aliases:
- /doc/release-notes/
- /meta/release-notes/
date: 2013-07-01
menu:
main:
parent: about
title: Release Notes
weight: 10
date: 2017-04-16
title: Older Release Notes
---
# **0.20.2** April 16th 2017
@@ -0,0 +1,6 @@
{{ define "main" }}
{{ range .Pages }}
<h1>{{ .Title }} {{ .Date.Format "Jan 2, 2006" }}</h1>
{{ .Content }}
{{ end }}
{{ end }}
View
@@ -0,0 +1,48 @@
build:
main: main.go
binary: hugo
ldflags_template: -s -w -X hugolib.BuildDate={{.Date}}
goos:
- darwin
- linux
- windows
- freebsd
- netbsd
- openbsd
- dragonfly
goarch:
- amd64
- 386
- arm
- arm64
fpm:
formats:
- deb
vendor: "gohugo.io"
url: "https://gohugo.io/"
maintainer: "<Bjørn Erik Pedersen bjorn.erik.pedersen@gmail.com>"
description: "A Fast and Flexible Static Site Generator built with love in GoLang."
license: "Apache 2.0"
archive:
format: tar.gz
format_overrides:
- goos: windows
format: zip
name_template: "{{.Binary}}_{{.Version}}_{{.Os}}-{{.Arch}}"
replacements:
amd64: 64bit
386: 32bit
arm: ARM
arm64: ARM64
darwin: macOS
linux: Linux
windows: Windows
openbsd: OpenBSD
netbsd: NetBSD
freebsd: FreeBSD
dragonfly: DragonFlyBSD
files:
- README.md
- LICENSE.md
release:
draft: true
View
@@ -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)
View
@@ -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.20
Number float32
// Increment this for bug releases
HugoPatchVersion = 2
)
PatchLevel int
// HugoVersionSuffix is the suffix used in the Hugo version string.
// It will be blank for release versions.
Suffix string
}
func (v HugoVersion) String() string {
return hugoVersion(v.Number, v.PatchLevel, v.Suffix)
}
// ReleaseVersion represents the release version.
func (v HugoVersion) ReleaseVersion() HugoVersion {
v.Suffix = ""
return v
}
// 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
// Next returns the next Hugo release version.
func (v HugoVersion) Next() HugoVersion {
return HugoVersion{Number: v.Number + 0.01}
}
// 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)
// Pre returns the previous Hugo release version.
func (v HugoVersion) Prev() HugoVersion {
return HugoVersion{Number: v.Number - 0.01}
}
// HugoReleaseVersion is same as HugoVersion, but no suffix.
func HugoReleaseVersion() string {
return hugoVersionNoSuffix(HugoVersionNumber, HugoPatchVersion)
// 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}
}
// NextHugoReleaseVersion returns the next Hugo release version.
func NextHugoReleaseVersion() string {
return hugoVersionNoSuffix(HugoVersionNumber+0.01, 0)
// 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 {
View
@@ -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) {
View
@@ -41,9 +41,9 @@ type HugoInfo struct {
func init() {
hugoInfo = &HugoInfo{
Version: helpers.HugoVersion(),
Version: helpers.CurrentHugoVersion.String(),
CommitHash: CommitHash,
BuildDate: BuildDate,
Generator: template.HTML(fmt.Sprintf(`<meta name="generator" content="Hugo %s" />`, helpers.HugoVersion())),
Generator: template.HTML(fmt.Sprintf(`<meta name="generator" content="Hugo %s" />`, helpers.CurrentHugoVersion.String())),
}
}
Oops, something went wrong.

0 comments on commit 550eba6

Please sign in to comment.