mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
c2235c6a62
commit
e627449c0a
5 changed files with 55 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
||||||
defaults: &defaults
|
defaults: &defaults
|
||||||
docker:
|
docker:
|
||||||
- image: bepsays/ci-goreleaser:1.14.3
|
- image: bepsays/ci-goreleaser:1.15.0
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: "0"
|
CGO_ENABLED: "0"
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ env:
|
||||||
git:
|
git:
|
||||||
depth: false
|
depth: false
|
||||||
go:
|
go:
|
||||||
- "1.13.11"
|
- "1.14.7"
|
||||||
- "1.14.3"
|
- "1.15"
|
||||||
- master
|
- master
|
||||||
|
|
||||||
arch:
|
arch:
|
||||||
|
|
|
@ -12,6 +12,9 @@ builds:
|
||||||
ldflags: -s -w -X github.com/gohugoio/hugo/common/hugo.buildDate={{.Date}} -X github.com/gohugoio/hugo/common/hugo.commitHash={{ .ShortCommit }}
|
ldflags: -s -w -X github.com/gohugoio/hugo/common/hugo.buildDate={{.Date}} -X github.com/gohugoio/hugo/common/hugo.commitHash={{ .ShortCommit }}
|
||||||
env:
|
env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
|
flags:
|
||||||
|
- -buildmode
|
||||||
|
- exe
|
||||||
goos:
|
goos:
|
||||||
- darwin
|
- darwin
|
||||||
- linux
|
- linux
|
||||||
|
@ -39,6 +42,8 @@ builds:
|
||||||
- CC=x86_64-w64-mingw32-gcc
|
- CC=x86_64-w64-mingw32-gcc
|
||||||
- CXX=x86_64-w64-mingw32-g++
|
- CXX=x86_64-w64-mingw32-g++
|
||||||
flags:
|
flags:
|
||||||
|
- -buildmode
|
||||||
|
- exe
|
||||||
- -tags
|
- -tags
|
||||||
- extended
|
- extended
|
||||||
goos:
|
goos:
|
||||||
|
@ -53,6 +58,8 @@ builds:
|
||||||
- CC=o64-clang
|
- CC=o64-clang
|
||||||
- CXX=o64-clang++
|
- CXX=o64-clang++
|
||||||
flags:
|
flags:
|
||||||
|
- -buildmode
|
||||||
|
- exe
|
||||||
- -tags
|
- -tags
|
||||||
- extended
|
- extended
|
||||||
goos:
|
goos:
|
||||||
|
@ -65,6 +72,8 @@ builds:
|
||||||
env:
|
env:
|
||||||
- CGO_ENABLED=1
|
- CGO_ENABLED=1
|
||||||
flags:
|
flags:
|
||||||
|
- -buildmode
|
||||||
|
- exe
|
||||||
- -tags
|
- -tags
|
||||||
- extended
|
- extended
|
||||||
goos:
|
goos:
|
||||||
|
|
51
magefile.go
51
magefile.go
|
@ -42,19 +42,25 @@ func init() {
|
||||||
os.Setenv("GO111MODULE", "on")
|
os.Setenv("GO111MODULE", "on")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func runWith(env map[string]string, cmd string, inArgs ...interface{}) error {
|
||||||
|
s := argsToStrings(inArgs...)
|
||||||
|
return sh.RunWith(env, cmd, s...)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Build hugo binary
|
// Build hugo binary
|
||||||
func Hugo() error {
|
func Hugo() error {
|
||||||
return sh.RunWith(flagEnv(), goexe, "build", "-ldflags", ldflags, "-tags", buildTags(), packageName)
|
return runWith(flagEnv(), goexe, "build", "-ldflags", ldflags, buildFlags(), "-tags", buildTags(), packageName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build hugo binary with race detector enabled
|
// Build hugo binary with race detector enabled
|
||||||
func HugoRace() error {
|
func HugoRace() error {
|
||||||
return sh.RunWith(flagEnv(), goexe, "build", "-race", "-ldflags", ldflags, "-tags", buildTags(), packageName)
|
return runWith(flagEnv(), goexe, "build", "-race", "-ldflags", ldflags, buildFlags(), "-tags", buildTags(), packageName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Install hugo binary
|
// Install hugo binary
|
||||||
func Install() error {
|
func Install() error {
|
||||||
return sh.RunWith(flagEnv(), goexe, "install", "-ldflags", ldflags, "-tags", buildTags(), packageName)
|
return runWith(flagEnv(), goexe, "install", "-ldflags", ldflags, buildFlags(), "-tags", buildTags(), packageName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uninstall hugo binary
|
// Uninstall hugo binary
|
||||||
|
@ -79,7 +85,7 @@ func Generate() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pkg := range generatorPackages {
|
for _, pkg := range generatorPackages {
|
||||||
if err := sh.RunWith(flagEnv(), goexe, "generate", path.Join(packageName, pkg)); err != nil {
|
if err := runWith(flagEnv(), goexe, "generate", path.Join(packageName, pkg)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,13 +182,13 @@ func Test386() error {
|
||||||
// Run tests
|
// Run tests
|
||||||
func Test() error {
|
func Test() error {
|
||||||
env := map[string]string{"GOFLAGS": testGoFlags()}
|
env := map[string]string{"GOFLAGS": testGoFlags()}
|
||||||
return runCmd(env, goexe, "test", "./...", "-tags", buildTags())
|
return runCmd(env, goexe, "test", "./...", buildFlags(), "-tags", buildTags())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run tests with race detector
|
// Run tests with race detector
|
||||||
func TestRace() error {
|
func TestRace() error {
|
||||||
env := map[string]string{"GOFLAGS": testGoFlags()}
|
env := map[string]string{"GOFLAGS": testGoFlags()}
|
||||||
return runCmd(env, goexe, "test", "-race", "./...", "-tags", buildTags())
|
return runCmd(env, goexe, "test", "-race", "./...", buildFlags(), "-tags", buildTags())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run gofmt linter
|
// Run gofmt linter
|
||||||
|
@ -318,11 +324,11 @@ func TestCoverHTML() error {
|
||||||
return sh.Run(goexe, "tool", "cover", "-html="+coverAll)
|
return sh.Run(goexe, "tool", "cover", "-html="+coverAll)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCmd(env map[string]string, cmd string, args ...string) error {
|
func runCmd(env map[string]string, cmd string, args ...interface{}) error {
|
||||||
if mg.Verbose() {
|
if mg.Verbose() {
|
||||||
return sh.RunWith(env, cmd, args...)
|
return runWith(env, cmd, args...)
|
||||||
}
|
}
|
||||||
output, err := sh.OutputWith(env, cmd, args...)
|
output, err := sh.OutputWith(env, cmd, argsToStrings(args...)...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprint(os.Stderr, output)
|
fmt.Fprint(os.Stderr, output)
|
||||||
}
|
}
|
||||||
|
@ -338,6 +344,13 @@ func isCI() bool {
|
||||||
return os.Getenv("CI") != ""
|
return os.Getenv("CI") != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func buildFlags() []string {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
return []string{"-buildmode", "exe"}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func buildTags() string {
|
func buildTags() string {
|
||||||
// To build the extended Hugo SCSS/SASS enabled version, build with
|
// To build the extended Hugo SCSS/SASS enabled version, build with
|
||||||
// HUGO_BUILD_TAGS=extended mage install etc.
|
// HUGO_BUILD_TAGS=extended mage install etc.
|
||||||
|
@ -346,3 +359,23 @@ func buildTags() string {
|
||||||
}
|
}
|
||||||
return "none"
|
return "none"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func argsToStrings(v ...interface{}) []string {
|
||||||
|
var args []string
|
||||||
|
for _, arg := range v {
|
||||||
|
switch v := arg.(type) {
|
||||||
|
case string:
|
||||||
|
if v != "" {
|
||||||
|
args = append(args, v)
|
||||||
|
}
|
||||||
|
case []string:
|
||||||
|
if v != nil {
|
||||||
|
args = append(args, v...)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
panic("invalid type")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return args
|
||||||
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ parts:
|
||||||
|
|
||||||
hugo:
|
hugo:
|
||||||
plugin: nil
|
plugin: nil
|
||||||
build-snaps: [go/1.14/stable]
|
build-snaps: [go/1.15/stable]
|
||||||
source: .
|
source: .
|
||||||
override-build: |
|
override-build: |
|
||||||
set -ex
|
set -ex
|
||||||
|
|
Loading…
Reference in a new issue