]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Build without the deploy feature by default
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 30 Oct 2024 08:29:38 +0000 (09:29 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 30 Oct 2024 10:46:40 +0000 (11:46 +0100)
Build tags setup changed to:

* !nodeploy => withdeploy
* nodeploy => !withdeploy

Also move the deploy feature out into its own release archives.

See #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 #12994

17 files changed:
.github/workflows/test.yml
.gitignore
Dockerfile
commands/deploy.go
commands/deploy_off.go
deploy/cloudfront.go
deploy/deploy.go
deploy/deploy_azure.go
deploy/deploy_test.go
deploy/deployconfig/deployConfig_test.go
deploy/google.go
hugoreleaser.toml
magefile.go
main_withdeploy_test.go [new file with mode: 0644]
testscripts/commands/deploy.txt [deleted file]
testscripts/commands/gen.txt
testscripts/withdeploy/deploy.txt [new file with mode: 0644]

index b513863c507b544cfd11e57ce4c155bdbf132c9d..05d9d23a2dba6570f1936176018f99f0a3a04618 100644 (file)
@@ -112,17 +112,17 @@ jobs:
           sass --version;
           mage -v check;
         env:
-          HUGO_BUILD_TAGS: extended
+          HUGO_BUILD_TAGS: extended,withdeploy
       - if: matrix.os == 'windows-latest'
         # See issue #11052. We limit the build to regular test (no -race flag) on Windows for now.
         name: Test
         run: |
           mage -v test;
         env:
-          HUGO_BUILD_TAGS: extended
+          HUGO_BUILD_TAGS: extended,withdeploy
       - name: Build tags
         run: |
-          go install -tags extended,nodeploy
+          go install -tags extended
       - if: matrix.os == 'ubuntu-latest'
         name: Build for dragonfly
         run: |
index b170fe204cc4b1c361010de0242c25a2a2d5cfe6..a1fa54656fa5fb385bf6ad35cad3c34faa2947c5 100644 (file)
@@ -1,3 +1,5 @@
 
 *.test
-imports.*
\ No newline at end of file
+imports.*
+dist/
+public/
index 65c4dbfb96faa8e34a2782559257e6410ade7c8b..6d1bf78c42d590223f88308688e0fa81c6bf2755 100755 (executable)
@@ -21,8 +21,8 @@ COPY --from=xx / /
 ARG TARGETPLATFORM
 RUN xx-apk add musl-dev gcc g++ 
 
-# Optionally set HUGO_BUILD_TAGS to "none" or "nodeploy" when building like so:
-# docker build --build-arg HUGO_BUILD_TAGS=nodeploy .
+# Optionally set HUGO_BUILD_TAGS to "none" or "withdeploy" when building like so:
+# docker build --build-arg HUGO_BUILD_TAGS=withdeploy .
 #
 # We build the extended version by default.
 ARG HUGO_BUILD_TAGS="extended"
index f0bc670cadfbd01afbb991504339159f7e8a9b88..f9c22be48f258cf4504956a22f96528b724ac12f 100644 (file)
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build !nodeploy
-// +build !nodeploy
-
-// Copyright 2024 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.
+//go:build withdeploy
+// +build withdeploy
 
 package commands
 
index 8a481bd968acbb02bcbb93f79defe7b2ca0742ea..7eb6429c51324f9803cec26079df71aa193474ca 100644 (file)
@@ -11,8 +11,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build nodeploy
-// +build nodeploy
+//go:build !withdeploy
+// +build !withdeploy
 
 // Copyright 2024 The Hugo Authors. All rights reserved.
 //
@@ -31,6 +31,7 @@ package commands
 
 import (
        "context"
+       "errors"
 
        "github.com/bep/simplecobra"
        "github.com/spf13/cobra"
@@ -40,7 +41,7 @@ func newDeployCommand() simplecobra.Commander {
        return &simpleCommand{
                name: "deploy",
                run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error {
-                       return nil
+                       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")
                },
                withc: func(cmd *cobra.Command, r *rootCommand) {
                        cmd.Hidden = true
index 4481eb52aa7378e2bb122502729d548f72df83ad..29c0a7f8c2cb6bce8463e3846d780682057f8974 100644 (file)
@@ -11,8 +11,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build !nodeploy
-// +build !nodeploy
+//go:build withdeploy
+// +build withdeploy
 
 package deploy
 
index a69e974b78ce23e7cf09dfab99393d5cd1cd9e0c..0c379ffb88969ec810751ea05666853f8650fd6c 100644 (file)
@@ -11,8 +11,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build !nodeploy
-// +build !nodeploy
+//go:build withdeploy
+// +build withdeploy
 
 package deploy
 
index fc7daca3b1e50be05a0b2e7a50822cc49fbcea03..521d8f0948fb52b7f100c6b65fbc22358e344a50 100644 (file)
@@ -11,8 +11,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build !solaris && !nodeploy
-// +build !solaris,!nodeploy
+//go:build !solaris && withdeploy
+// +build !solaris,withdeploy
 
 package deploy
 
index 17dffc25af49d74daa9599642037d73d5f518447..f290d6c81d896f4378639aa8d5ec70f69b271ef8 100644 (file)
@@ -11,8 +11,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build !nodeploy
-// +build !nodeploy
+//go:build withdeploy
+// +build withdeploy
 
 package deploy
 
index 0b92a5cb11e8a2c145807b6332bde01900ab0b87..8a3ad2d8af6af8b644b8dfebf323cd2dffaa5cfb 100644 (file)
@@ -11,8 +11,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build !nodeploy
-// +build !nodeploy
+//go:build withdeploy
+// +build withdeploy
 
 package deployconfig
 
index 6e492bc01d1451d17061523f9002782ef60ca5e3..e4683aa817e6c500e0855f086f0eba1ea27a1bd1 100644 (file)
@@ -11,8 +11,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build !nodeploy
-// +build !nodeploy
+//go:build withdeploy
+// +build withdeploy
 
 package deploy
 
index d516bd34bef3fc74baca81fd03dc8f88a8ef99df..8c3693739818c5324f20fab4c88b6391f3241f64 100644 (file)
@@ -119,6 +119,24 @@ archive_alias_replacements = { "linux-amd64.tar.gz" = "Linux-64bit.tar.gz" }
         [[builds.os.archs]]
             goarch = "amd64"
 
+[[builds]]
+    path = "container1/unix/extended-withdeploy"
+
+    [builds.build_settings]
+        flags = ["-buildmode", "exe", "-tags", "extended,withdeploy"]
+        env   = ["CGO_ENABLED=1"]
+
+    [[builds.os]]
+        goos = "darwin"
+        [builds.os.build_settings]
+            env = ["CGO_ENABLED=1", "CC=o64-clang", "CXX=o64-clang++"]
+        [[builds.os.archs]]
+            goarch = "universal"
+    [[builds.os]]
+        goos = "linux"
+        [[builds.os.archs]]
+            goarch = "amd64"
+
 [[builds]]
     path = "container2/linux/extended"
 
@@ -173,6 +191,10 @@ archive_alias_replacements = { "linux-amd64.tar.gz" = "Linux-64bit.tar.gz" }
     paths = ["builds/container1/unix/extended/**"]
     [archives.archive_settings]
         name_template = "{{ .Project }}_extended_{{ .Tag | trimPrefix `v` }}_{{ .Goos }}-{{ .Goarch }}"
+[[archives]]
+    paths = ["builds/container1/unix/extended-withdeploy/**"]
+    [archives.archive_settings]
+        name_template = "{{ .Project }}_extended_withdeploy_{{ .Tag | trimPrefix `v` }}_{{ .Goos }}-{{ .Goarch }}"
 [[archives]]
     # Only extended builds in container2.
     paths = ["builds/container2/**"]
index 142b9160a5a3aecb1697e9868ad6c4dd4850f91d..9919e0185c481c31b0bf72eb4a534df79e1aea56 100644 (file)
@@ -334,7 +334,7 @@ func buildFlags() []string {
 func buildTags() string {
        // To build the extended Hugo SCSS/SASS enabled version, build with
        // HUGO_BUILD_TAGS=extended mage install etc.
-       // To build without `hugo deploy` for smaller binary, use HUGO_BUILD_TAGS=nodeploy
+       // To build with `hugo deploy`, use HUGO_BUILD_TAGS=withdeploy
        if envtags := os.Getenv("HUGO_BUILD_TAGS"); envtags != "" {
                return envtags
        }
diff --git a/main_withdeploy_test.go b/main_withdeploy_test.go
new file mode 100644 (file)
index 0000000..de50313
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright 2024 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.
+
+//go:build withdeploy
+// +build withdeploy
+
+package main
+
+import (
+       "testing"
+
+       "github.com/rogpeppe/go-internal/testscript"
+)
+
+func TestWithdeploy(t *testing.T) {
+       p := commonTestScriptsParam
+       p.Dir = "testscripts/withdeploy"
+       testscript.Run(t, p)
+}
diff --git a/testscripts/commands/deploy.txt b/testscripts/commands/deploy.txt
deleted file mode 100644 (file)
index 2586f8b..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-# Test the deploy command.
-
-hugo deploy -h
-stdout 'Deploy your site to a cloud provider'
-mkdir mybucket
-hugo deploy --target mydeployment --invalidateCDN=false
-grep 'hello' mybucket/index.html
-replace  public/index.html 'hello' 'changed'
-hugo deploy --target mydeployment --dryRun
-stdout 'Would upload: index.html'
-stdout 'Would invalidate CloudFront CDN with ID foobar'
--- hugo.toml --
-disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"]
-baseURL = "https://example.org/"
-[deployment]
-[[deployment.targets]]
-name = "myfirst"
-url="gs://asdfasdf"
-[[deployment.targets]]
-name = "mydeployment"
-url="file://./mybucket"
-cloudFrontDistributionID = "foobar"
--- public/index.html --
-<html><body>hello</body></html>
index b8fe9d2dcbf98c02838c5406a3d50c1c9494dec0..092b4e129208361ff759fb9a8667c4cb98c0e6a9 100644 (file)
@@ -1,17 +1,12 @@
 # Test the gen commands.
-# Note that adding new commands will require updating the NUM_COMMANDS value.
-env NUM_COMMANDS=44
 
 hugo gen -h
 stdout 'Generate documentation for your project using Hugo''s documentation engine, including syntax highlighting for various programming languages\.'
-
 hugo gen doc --dir clidocs
-checkfilecount $NUM_COMMANDS clidocs
 
 hugo gen man -h
 stdout 'up-to-date man pages'
 hugo gen man --dir manpages
-checkfilecount $NUM_COMMANDS manpages
 
 hugo gen chromastyles -h
 stdout 'Generate CSS stylesheet for the Chroma code highlighter'
diff --git a/testscripts/withdeploy/deploy.txt b/testscripts/withdeploy/deploy.txt
new file mode 100644 (file)
index 0000000..2586f8b
--- /dev/null
@@ -0,0 +1,24 @@
+# Test the deploy command.
+
+hugo deploy -h
+stdout 'Deploy your site to a cloud provider'
+mkdir mybucket
+hugo deploy --target mydeployment --invalidateCDN=false
+grep 'hello' mybucket/index.html
+replace  public/index.html 'hello' 'changed'
+hugo deploy --target mydeployment --dryRun
+stdout 'Would upload: index.html'
+stdout 'Would invalidate CloudFront CDN with ID foobar'
+-- hugo.toml --
+disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"]
+baseURL = "https://example.org/"
+[deployment]
+[[deployment.targets]]
+name = "myfirst"
+url="gs://asdfasdf"
+[[deployment.targets]]
+name = "mydeployment"
+url="file://./mybucket"
+cloudFrontDistributionID = "foobar"
+-- public/index.html --
+<html><body>hello</body></html>