From 2784cd67ccd20e6870495151633a6ae0d1e29cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 30 Oct 2024 09:29:38 +0100 Subject: [PATCH] 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 #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 --- Dockerfile | 4 ++-- commands/deploy.go | 4 ++-- commands/deploy_off.go | 4 ++-- deploy/cloudfront.go | 4 ++-- deploy/deploy.go | 4 ++-- deploy/deploy_azure.go | 4 ++-- deploy/deploy_test.go | 4 ++-- deploy/deployconfig/deployConfig_test.go | 4 ++-- deploy/google.go | 4 ++-- hugoreleaser.toml | 22 ++++++++++++++++++++++ magefile.go | 2 +- 11 files changed, 41 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 65c4dbfb96f..6d1bf78c42d 100755 --- a/Dockerfile +++ b/Dockerfile @@ -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" diff --git a/commands/deploy.go b/commands/deploy.go index f0bc670cadf..582c99beab3 100644 --- a/commands/deploy.go +++ b/commands/deploy.go @@ -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. // diff --git a/commands/deploy_off.go b/commands/deploy_off.go index 8a481bd968a..68c7422b1d9 100644 --- a/commands/deploy_off.go +++ b/commands/deploy_off.go @@ -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. // diff --git a/deploy/cloudfront.go b/deploy/cloudfront.go index 4481eb52aa7..29c0a7f8c2c 100644 --- a/deploy/cloudfront.go +++ b/deploy/cloudfront.go @@ -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 diff --git a/deploy/deploy.go b/deploy/deploy.go index a69e974b78c..0c379ffb889 100644 --- a/deploy/deploy.go +++ b/deploy/deploy.go @@ -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 diff --git a/deploy/deploy_azure.go b/deploy/deploy_azure.go index fc7daca3b1e..521d8f0948f 100644 --- a/deploy/deploy_azure.go +++ b/deploy/deploy_azure.go @@ -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 diff --git a/deploy/deploy_test.go b/deploy/deploy_test.go index 17dffc25af4..f290d6c81d8 100644 --- a/deploy/deploy_test.go +++ b/deploy/deploy_test.go @@ -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 diff --git a/deploy/deployconfig/deployConfig_test.go b/deploy/deployconfig/deployConfig_test.go index 0b92a5cb11e..8a3ad2d8af6 100644 --- a/deploy/deployconfig/deployConfig_test.go +++ b/deploy/deployconfig/deployConfig_test.go @@ -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 diff --git a/deploy/google.go b/deploy/google.go index 6e492bc01d1..e4683aa817e 100644 --- a/deploy/google.go +++ b/deploy/google.go @@ -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 diff --git a/hugoreleaser.toml b/hugoreleaser.toml index d516bd34bef..f8b457e9b1f 100644 --- a/hugoreleaser.toml +++ b/hugoreleaser.toml @@ -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_with_deploy_{{ .Tag | trimPrefix `v` }}_{{ .Goos }}-{{ .Goarch }}" [[archives]] # Only extended builds in container2. paths = ["builds/container2/**"] diff --git a/magefile.go b/magefile.go index 142b9160a5a..9919e0185c4 100644 --- a/magefile.go +++ b/magefile.go @@ -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 }