Skip to content

Commit 89bd025

Browse files
committed
Build without the deploy feature by default
Build tags setup changed to: * !nodeploy => withdeploy * nodeploy => !withdeploy Also move the deploy feature out into its own release archives. See gohugoio#12994 for the primary motivation for this change. But this also greatly reduces the number of dependencies in Hugo when you don't need this feature and cuts the binary size greatly. Fixes gohugoio#12994
1 parent 62567d3 commit 89bd025

16 files changed

+78
-42
lines changed

.github/workflows/test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,17 @@ jobs:
112112
sass --version;
113113
mage -v check;
114114
env:
115-
HUGO_BUILD_TAGS: extended
115+
HUGO_BUILD_TAGS: extended,withdeploy
116116
- if: matrix.os == 'windows-latest'
117117
# See issue #11052. We limit the build to regular test (no -race flag) on Windows for now.
118118
name: Test
119119
run: |
120120
mage -v test;
121121
env:
122-
HUGO_BUILD_TAGS: extended
122+
HUGO_BUILD_TAGS: extended,withdeploy
123123
- name: Build tags
124124
run: |
125-
go install -tags extended,nodeploy
125+
go install -tags extended
126126
- if: matrix.os == 'ubuntu-latest'
127127
name: Build for dragonfly
128128
run: |

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11

22
*.test
3-
imports.*
3+
imports.*
4+
dist/
5+
public/

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ COPY --from=xx / /
2121
ARG TARGETPLATFORM
2222
RUN xx-apk add musl-dev gcc g++
2323

24-
# Optionally set HUGO_BUILD_TAGS to "none" or "nodeploy" when building like so:
25-
# docker build --build-arg HUGO_BUILD_TAGS=nodeploy .
24+
# Optionally set HUGO_BUILD_TAGS to "none" or "withdeploy" when building like so:
25+
# docker build --build-arg HUGO_BUILD_TAGS=withdeploy .
2626
#
2727
# We build the extended version by default.
2828
ARG HUGO_BUILD_TAGS="extended"

commands/deploy.go

+2-15
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
//go:build !nodeploy
15-
// +build !nodeploy
16-
17-
// Copyright 2024 The Hugo Authors. All rights reserved.
18-
//
19-
// Licensed under the Apache License, Version 2.0 (the "License");
20-
// you may not use this file except in compliance with the License.
21-
// You may obtain a copy of the License at
22-
// http://www.apache.org/licenses/LICENSE-2.0
23-
//
24-
// Unless required by applicable law or agreed to in writing, software
25-
// distributed under the License is distributed on an "AS IS" BASIS,
26-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27-
// See the License for the specific language governing permissions and
28-
// limitations under the License.
14+
//go:build withdeploy
15+
// +build withdeploy
2916

3017
package commands
3118

commands/deploy_off.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
//go:build nodeploy
15-
// +build nodeploy
14+
//go:build !withdeploy
15+
// +build !withdeploy
1616

1717
// Copyright 2024 The Hugo Authors. All rights reserved.
1818
//
@@ -31,6 +31,7 @@ package commands
3131

3232
import (
3333
"context"
34+
"errors"
3435

3536
"github.com/bep/simplecobra"
3637
"github.com/spf13/cobra"
@@ -40,7 +41,7 @@ func newDeployCommand() simplecobra.Commander {
4041
return &simpleCommand{
4142
name: "deploy",
4243
run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error {
43-
return nil
44+
return errors.New("deploy not supported in this version of Hugo; install a release with 'withdeploy' in the archive filename or build yourself with the 'withdeploy' build tag. Also see https://github.com/gohugoio/hugo/pull/12995")
4445
},
4546
withc: func(cmd *cobra.Command, r *rootCommand) {
4647
cmd.Hidden = true

deploy/cloudfront.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
//go:build !nodeploy
15-
// +build !nodeploy
14+
//go:build withdeploy
15+
// +build withdeploy
1616

1717
package deploy
1818

deploy/deploy.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
//go:build !nodeploy
15-
// +build !nodeploy
14+
//go:build withdeploy
15+
// +build withdeploy
1616

1717
package deploy
1818

deploy/deploy_azure.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
//go:build !solaris && !nodeploy
15-
// +build !solaris,!nodeploy
14+
//go:build !solaris && withdeploy
15+
// +build !solaris,withdeploy
1616

1717
package deploy
1818

deploy/deploy_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
//go:build !nodeploy
15-
// +build !nodeploy
14+
//go:build withdeploy
15+
// +build withdeploy
1616

1717
package deploy
1818

deploy/deployconfig/deployConfig_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
//go:build !nodeploy
15-
// +build !nodeploy
14+
//go:build withdeploy
15+
// +build withdeploy
1616

1717
package deployconfig
1818

deploy/google.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
//go:build !nodeploy
15-
// +build !nodeploy
14+
//go:build withdeploy
15+
// +build withdeploy
1616

1717
package deploy
1818

hugoreleaser.toml

+22
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,24 @@ archive_alias_replacements = { "linux-amd64.tar.gz" = "Linux-64bit.tar.gz" }
119119
[[builds.os.archs]]
120120
goarch = "amd64"
121121

122+
[[builds]]
123+
path = "container1/unix/extended-withdeploy"
124+
125+
[builds.build_settings]
126+
flags = ["-buildmode", "exe", "-tags", "extended,withdeploy"]
127+
env = ["CGO_ENABLED=1"]
128+
129+
[[builds.os]]
130+
goos = "darwin"
131+
[builds.os.build_settings]
132+
env = ["CGO_ENABLED=1", "CC=o64-clang", "CXX=o64-clang++"]
133+
[[builds.os.archs]]
134+
goarch = "universal"
135+
[[builds.os]]
136+
goos = "linux"
137+
[[builds.os.archs]]
138+
goarch = "amd64"
139+
122140
[[builds]]
123141
path = "container2/linux/extended"
124142

@@ -173,6 +191,10 @@ archive_alias_replacements = { "linux-amd64.tar.gz" = "Linux-64bit.tar.gz" }
173191
paths = ["builds/container1/unix/extended/**"]
174192
[archives.archive_settings]
175193
name_template = "{{ .Project }}_extended_{{ .Tag | trimPrefix `v` }}_{{ .Goos }}-{{ .Goarch }}"
194+
[[archives]]
195+
paths = ["builds/container1/unix/extended-withdeploy/**"]
196+
[archives.archive_settings]
197+
name_template = "{{ .Project }}_extended_withdeploy_{{ .Tag | trimPrefix `v` }}_{{ .Goos }}-{{ .Goarch }}"
176198
[[archives]]
177199
# Only extended builds in container2.
178200
paths = ["builds/container2/**"]

magefile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ func buildFlags() []string {
334334
func buildTags() string {
335335
// To build the extended Hugo SCSS/SASS enabled version, build with
336336
// HUGO_BUILD_TAGS=extended mage install etc.
337-
// To build without `hugo deploy` for smaller binary, use HUGO_BUILD_TAGS=nodeploy
337+
// To build with `hugo deploy`, use HUGO_BUILD_TAGS=withdeploy
338338
if envtags := os.Getenv("HUGO_BUILD_TAGS"); envtags != "" {
339339
return envtags
340340
}

main_withdeploy_test.go

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2024 The Hugo Authors. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
//go:build withdeploy
15+
// +build withdeploy
16+
17+
package main
18+
19+
import (
20+
"testing"
21+
22+
"github.com/rogpeppe/go-internal/testscript"
23+
)
24+
25+
func TestWithdeploy(t *testing.T) {
26+
p := commonTestScriptsParam
27+
p.Dir = "testscripts/withdeploy"
28+
testscript.Run(t, p)
29+
}

testscripts/commands/gen.txt

-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
# Test the gen commands.
2-
# Note that adding new commands will require updating the NUM_COMMANDS value.
3-
env NUM_COMMANDS=44
42

53
hugo gen -h
64
stdout 'Generate documentation for your project using Hugo''s documentation engine, including syntax highlighting for various programming languages\.'
7-
85
hugo gen doc --dir clidocs
9-
checkfilecount $NUM_COMMANDS clidocs
106

117
hugo gen man -h
128
stdout 'up-to-date man pages'
139
hugo gen man --dir manpages
14-
checkfilecount $NUM_COMMANDS manpages
1510

1611
hugo gen chromastyles -h
1712
stdout 'Generate CSS stylesheet for the Chroma code highlighter'
File renamed without changes.

0 commit comments

Comments
 (0)