Upgrade Hugo to 0.52 (#11552)

* Update Hugo version and apply HTML minification to production builds

* Use full flag names for clarity

* Remove Hugo installation logic out of Travis config and into Makefile

* Add Hugo version checking script

* Fix Netlify config version
pull/12232/head
Luc Perkins 2019-01-15 10:56:39 -08:00 committed by Kubernetes Prow Robot
parent 9c1248e467
commit aac7862a06
5 changed files with 37 additions and 14 deletions

View File

@ -2,9 +2,6 @@ language: go
go:
- 1.10.2
env:
- HUGO_VERSION=0.49
jobs:
include:
- name: "Testing examples"
@ -26,9 +23,6 @@ jobs:
- go test -v k8s.io/website/content/en/examples
- name: "Hugo build"
install:
- curl -L https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-64bit.tar.gz | tar -xz
- mkdir -p ${TRAVIS_HOME}/bin
- mv hugo ${TRAVIS_HOME}/bin
- export PATH=${TRAVIS_HOME}/bin:$PATH
- make travis-hugo-build
script:
- hugo

View File

@ -1,5 +1,5 @@
DOCKER = docker
HUGO_VERSION = 0.49
HUGO_VERSION = 0.52
DOCKER_IMAGE = kubernetes-hugo
DOCKER_RUN = $(DOCKER) run --rm --interactive --tty --volume $(CURDIR):/src
NODE_BIN = node_modules/.bin
@ -13,10 +13,10 @@ help: ## Show this help.
all: build ## Build site with production settings and put deliverables in ./public
build: ## Build site with production settings and put deliverables in ./public
hugo
hugo --minify
build-preview: ## Build site with drafts and future posts enabled
hugo -D -F
hugo --buildDrafts --buildFuture
functions-build:
$(NETLIFY_FUNC) build functions-src
@ -24,9 +24,9 @@ functions-build:
check-headers-file:
scripts/check-headers-file.sh
production-build: build check-headers-file ## Build the production site and ensure that noindex headers aren't added
production-build: check-hugo-versions build check-headers-file ## Build the production site and ensure that noindex headers aren't added
non-production-build: ## Build the non-production site, which adds noindex headers to prevent indexing
non-production-build: check-hugo-versions ## Build the non-production site, which adds noindex headers to prevent indexing
hugo --enableGitInfo
sass-build:
@ -36,7 +36,7 @@ sass-develop:
scripts/sass.sh develop
serve: ## Boot the development server.
hugo server --ignoreCache --disableFastRender --buildFuture
hugo server --ignoreCache --buildFuture
docker-image:
$(DOCKER) build . --tag $(DOCKER_IMAGE) --build-arg HUGO_VERSION=$(HUGO_VERSION)
@ -46,3 +46,13 @@ docker-build:
docker-serve:
$(DOCKER_RUN) -p 1313:1313 $(DOCKER_IMAGE) hugo server --buildFuture --bind 0.0.0.0
# This command is used only by Travis CI; do not run this locally
travis-hugo-build:
curl -L https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-64bit.tar.gz | tar -xz
mkdir -p ${TRAVIS_HOME}/bin
mv hugo ${TRAVIS_HOME}/bin
export PATH=${TRAVIS_HOME}/bin:$PATH
check-hugo-versions:
scripts/hugo-version-check.sh $(HUGO_VERSION)

View File

@ -4,6 +4,7 @@ title = "Kubernetes"
defaultContentLanguage = "en"
defaultContentLanguageInSubdir = false
enableRobotsTXT = true
disableBrowserError = true
disableKinds = ["taxonomy", "taxonomyTerm"]

View File

@ -7,7 +7,7 @@ functions = "functions"
command = "make non-production-build"
[build.environment]
HUGO_VERSION = "0.49"
HUGO_VERSION = "0.52"
[context.production.environment]
HUGO_BASEURL = "https://kubernetes.io/"

18
scripts/hugo-version-check.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
MAIN_HUGO_VERSION=$1
NETLIFY_HUGO_VERSION=$(cat netlify.toml | grep HUGO_VERSION | awk '{ print $3 }' | tr -d '"')
echo ${NETLIFY_HUGO_VERSION}
if [[ ${MAIN_HUGO_VERSION} != ${NETLIFY_HUGO_VERSION} ]]; then
echo """
[FAILURE] The Hugo version set in the Makefile is ${MAIN_HUGO_VERSION} while the version in netlify.toml is ${NETLIFY_HUGO_VERSION}
[FAILURE] Please update these versions so that they are same (consider the higher of the two versions as canonical).
"""
exit 1
else
echo "[SUCCESS] The Hugo versions match between the Makefile and netlify.toml"
exit 0
fi