From fa9be7f4b64c27e5b381a10674b85ad7ce8404d4 Mon Sep 17 00:00:00 2001 From: Jack Hickey <133868041+nginx-jack@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:06:34 +0100 Subject: [PATCH] Add hugo version check and theme update to Makefile (#6599) --- docs/Makefile | 32 ++++++++++++++++---------------- docs/go.mod | 4 ++-- docs/go.sum | 4 ++-- docs/hugo-entrypoint.sh | 4 ++++ 4 files changed, 24 insertions(+), 20 deletions(-) create mode 100755 docs/hugo-entrypoint.sh diff --git a/docs/Makefile b/docs/Makefile index 0781d904b5..2748c484f6 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,40 +1,41 @@ HUGO?=hugo -HUGO_IMG?=hugomods/hugo:0.134.1 +HUGO_VERSION?=$(shell hugo version 2>/dev/null | awk '{print $$2}' | cut -d '.' -f 2) +HUGO_IMG?=hugomods/hugo:std-go-git-0.134.3 THEME_MODULE = github.com/nginxinc/nginx-hugo-theme -THEME_VERSION ?= $(shell curl -s https://api.github.com/repos/nginxinc/nginx-hugo-theme/releases/latest | jq -r ".tag_name") -ifeq (, $(shell ${HUGO} version 2> /dev/null)) -ifeq (, $(shell docker version 2> /dev/null)) - $(error Docker and Hugo are not installed. Hugo (<0.91) or Docker are required to build the local preview.) +HUGO_CI=docker run --rm -v ${CURDIR}:/src ${HUGO_IMG} hugo + +ifeq ($(shell [ $(HUGO_VERSION) -gt 133 2>/dev/null ] && echo true || echo false), true) + $(info Hugo is available and has a version greater than 133. Proceeding with build.) else - HUGO=docker run --rm -it -v ${CURDIR}:/src -p 1313:1313 ${HUGO_IMG} hugo --bind 0.0.0.0 -p 1313 + $(warning Hugo is not available or using a version less than 134. Attempting to use docker. HUGO_VERSION=$(HUGO_VERSION)) + HUGO=docker run --rm -it -v ${CURDIR}:/src -p 1313:1313 ${HUGO_IMG} /src/hugo-entrypoint.sh + ifeq (, $(shell docker version 2> /dev/null)) + $(error Hugo (>0.134) or Docker are required to build the local previews.) + endif endif -endif - -HUGO_CI=docker run --rm -v ${CURDIR}:/src ${HUGO_IMG} hugo MARKDOWNLINT?=markdownlint MARKDOWNLINT_IMG?=ghcr.io/igorshubovych/markdownlint-cli:latest ifeq (, $(shell ${MARKDOWNLINT} version 2> /dev/null)) ifeq (, $(shell docker version 2> /dev/null)) - $(error Docker and markdownlint are not installed. markdownlint or Docker are required to lint.) -endif else MARKDOWNLINT=docker run --rm -i -v ${CURDIR}:/src --workdir /src ${MARKDOWNLINT_IMG} endif +endif MARKDOWNLINKCHECK?=markdown-link-check MARKDOWNLINKCHECK_IMG?=ghcr.io/tcort/markdown-link-check:stable ifeq (, $(shell ${MARKDOWNLINKCHECK} --version 2> /dev/null)) ifeq (, $(shell docker version 2> /dev/null)) - $(error Docker and markdown-link-check are not installed. markdown-link-check or Docker are required to check links.) -endif else - MARKDOWNLINKCHECK=docker run --rm -it -v ${CURDIR}:/site --workdir /site ${MARKDOWNLINKCHECK_IMG} + MARKDOWNLINKCHECK=docker run --rm -it -v ${CURDIR}:/docs --workdir /docs ${MARKDOWNLINKCHECK_IMG} endif +endif + .PHONY: docs docs-draft docs-local clean hugo-get hugo-tidy lint-markdown link-check @@ -51,11 +52,10 @@ drafts: ${HUGO} --bind 0.0.0.0 -p 1313 server -D --disableFastRender clean: - hugo mod clean [ -d "public" ] && rm -rf "public" hugo-get: - hugo mod get $(THEME_MODULE)@$(THEME_VERSION) + hugo mod get -u github.com/nginxinc/nginx-hugo-theme hugo-tidy: hugo mod tidy diff --git a/docs/go.mod b/docs/go.mod index 8266aa09ba..79c50308f6 100644 --- a/docs/go.mod +++ b/docs/go.mod @@ -1,5 +1,5 @@ module github.com/nginxinc/kubernetes-ingress/docs -go 1.23.0 +go 1.23 -require github.com/nginxinc/nginx-hugo-theme v0.41.17 // indirect +require github.com/nginxinc/nginx-hugo-theme v0.41.19 // indirect diff --git a/docs/go.sum b/docs/go.sum index 1ba7251286..5dbffbf03f 100644 --- a/docs/go.sum +++ b/docs/go.sum @@ -1,2 +1,2 @@ -github.com/nginxinc/nginx-hugo-theme v0.41.17 h1:KtF0TFQYXmVratjKVGEodWYFNbtxeOdrZLa9zi70BtA= -github.com/nginxinc/nginx-hugo-theme v0.41.17/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M= +github.com/nginxinc/nginx-hugo-theme v0.41.19 h1:CyZOhU8q0p3nQ+ZTFRx7c/Dq9rxV1mShADIHz0vDoHo= +github.com/nginxinc/nginx-hugo-theme v0.41.19/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M= diff --git a/docs/hugo-entrypoint.sh b/docs/hugo-entrypoint.sh new file mode 100755 index 0000000000..dc72123528 --- /dev/null +++ b/docs/hugo-entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +hugo mod get -u github.com/nginxinc/nginx-hugo-theme +hugo $*