diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 401fb12bfb..68e5ab53ef 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -20,6 +20,7 @@ jobs: - lint - shellcheck - validate-vendor + - update-authors # ensure authors update target runs fine steps: - name: Checkout diff --git a/docker-bake.hcl b/docker-bake.hcl index b8dbed6aec..c91bd421f0 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -114,6 +114,20 @@ target "mod-outdated" { output = ["type=cacheonly"] } +target "validate-authors" { + inherits = ["_common"] + dockerfile = "./dockerfiles/Dockerfile.authors" + target = "validate" + output = ["type=cacheonly"] +} + +target "update-authors" { + inherits = ["_common"] + dockerfile = "./dockerfiles/Dockerfile.authors" + target = "update" + output = ["."] +} + target "test" { target = "test" output = ["type=cacheonly"] diff --git a/docker.Makefile b/docker.Makefile index 18f3159973..e1848a4fc7 100644 --- a/docker.Makefile +++ b/docker.Makefile @@ -97,7 +97,7 @@ mod-outdated: ## check outdated dependencies .PHONY: authors authors: ## generate AUTHORS file from git history - $(DOCKER_RUN) -it $(DEV_DOCKER_IMAGE_NAME) make authors + docker buildx bake update-authors .PHONY: manpages manpages: build_docker_image ## generate man pages from go source and markdown diff --git a/dockerfiles/Dockerfile.authors b/dockerfiles/Dockerfile.authors new file mode 100644 index 0000000000..71cd1decbf --- /dev/null +++ b/dockerfiles/Dockerfile.authors @@ -0,0 +1,23 @@ +# syntax=docker/dockerfile:1.3-labs + +FROM alpine:3.14 AS gen +RUN apk add --no-cache bash git +WORKDIR /src +RUN --mount=type=bind,target=. \ + mkdir /out && ./scripts/docs/generate-authors.sh /out + +FROM scratch AS update +COPY --from=gen /out / + +FROM gen AS validate +RUN --mount=type=bind,target=.,rw <&2 'ERROR: Authors result differs. Please update with "make -f docker.Makefile authors"' + echo "$diff" + exit 1 +fi +EOT diff --git a/scripts/docs/generate-authors.sh b/scripts/docs/generate-authors.sh index 620897d371..b76ef325eb 100755 --- a/scripts/docs/generate-authors.sh +++ b/scripts/docs/generate-authors.sh @@ -1,10 +1,8 @@ #!/usr/bin/env bash set -e -cd "$(dirname "$(readlink -f "${BASH_SOURCE[*]}")")/../.." - # see also ".mailmap" for how email addresses and names are deduplicated - +OUT="${1:-.}" { cat <<-'EOH' # This file lists all individuals having contributed content to the repository. @@ -12,4 +10,5 @@ cd "$(dirname "$(readlink -f "${BASH_SOURCE[*]}")")/../.." EOH echo git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf -} > AUTHORS +} > "$OUT/AUTHORS" +cat "$OUT/AUTHORS"