Skip to content

Commit

Permalink
Upgrade Hugo to 0.52 (kubernetes#11552)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lucperkins authored and k8s-ci-robot committed Jan 15, 2019
1 parent 9c1248e commit aac7862
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
8 changes: 1 addition & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ language: go
go:
- 1.10.2

env:
- HUGO_VERSION=0.49

jobs:
include:
- name: "Testing examples"
Expand All @@ -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
22 changes: 16 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,20 +13,20 @@ 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

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:
Expand All @@ -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)
Expand All @@ -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)
1 change: 1 addition & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ title = "Kubernetes"
defaultContentLanguage = "en"
defaultContentLanguageInSubdir = false
enableRobotsTXT = true
disableBrowserError = true

disableKinds = ["taxonomy", "taxonomyTerm"]

Expand Down
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
18 changes: 18 additions & 0 deletions scripts/hugo-version-check.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit aac7862

Please sign in to comment.