docs: include required tools in source tree

In order to be able to build the documentation without internet access
(as is required by some distribution build systems), all of the source
code needed for the build needs to be available in the source tarball.

This used to be possible with the docker-cli sources but was
accidentally broken with some CI changes that switched to downloading
the tools (by modifying go.mod as part of the docs build script).

This pattern also maked documentation builds less reproducible since the
tool version used was not based on the source code version.

Fixes: 7dc35c03fc ("validate manpages target")
Fixes: a650f4ddd0 ("switch to cli-docs-tool for yaml docs generation")
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Aleksa Sarai
2024-12-16 17:21:02 +11:00
committed by Sebastiaan van Stijn
parent b199ece92a
commit 47775a8fa0
50 changed files with 11144 additions and 103 deletions

View File

@ -4,32 +4,18 @@ set -eu
: "${MD2MAN_VERSION=v2.0.6}"
export GO111MODULE=auto
function clean {
rm -rf "$buildir"
function clean() {
rm -f go.mod
}
buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX)
export GO111MODULE=auto
trap clean EXIT
(
set -x
cp -r . "$buildir/"
cd "$buildir"
# init dummy go.mod
./scripts/vendor init
# install go-md2man and copy man/tools.go in root folder
# to be able to fetch the required dependencies
go mod edit -modfile=vendor.mod -require=github.com/cpuguy83/go-md2man/v2@${MD2MAN_VERSION}
cp man/tools.go .
# update vendor
./scripts/vendor update
# build gen-manpages
go build -mod=vendor -modfile=vendor.mod -tags manpages -o /tmp/gen-manpages ./man/generate.go
# build go-md2man
go build -mod=vendor -modfile=vendor.mod -o /tmp/go-md2man ./vendor/github.com/cpuguy83/go-md2man/v2
)
./scripts/vendor init
# build gen-manpages
go build -mod=vendor -modfile=vendor.mod -tags manpages -o /tmp/gen-manpages ./man/generate.go
# build go-md2man
go build -mod=vendor -modfile=vendor.mod -o /tmp/go-md2man ./vendor/github.com/cpuguy83/go-md2man/v2
mkdir -p man/man1
(set -x ; /tmp/gen-manpages --root "." --target "$(pwd)/man/man1")

View File

@ -4,30 +4,16 @@ set -eu
: "${CLI_DOCS_TOOL_VERSION=v0.9.0}"
export GO111MODULE=auto
function clean {
rm -rf "$buildir"
function clean() {
rm -f go.mod
}
buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX)
export GO111MODULE=auto
trap clean EXIT
(
set -x
cp -r . "$buildir/"
cd "$buildir"
# init dummy go.mod
./scripts/vendor init
# install cli-docs-tool and copy docs/tools.go in root folder
# to be able to fetch the required dependencies
go mod edit -modfile=vendor.mod -require=github.com/docker/cli-docs-tool@${CLI_DOCS_TOOL_VERSION}
cp docs/generate/tools.go .
# update vendor
./scripts/vendor update
# build docsgen
go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
)
./scripts/vendor init
# build docsgen
go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
(
set -x

View File

@ -4,30 +4,16 @@ set -eu
: "${CLI_DOCS_TOOL_VERSION=v0.9.0}"
export GO111MODULE=auto
function clean {
rm -rf "$buildir"
function clean() {
rm -f go.mod
}
buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX)
export GO111MODULE=auto
trap clean EXIT
(
set -x
cp -r . "$buildir/"
cd "$buildir"
# init dummy go.mod
./scripts/vendor init
# install cli-docs-tool and copy docs/tools.go in root folder
# to be able to fetch the required dependencies
go mod edit -modfile=vendor.mod -require=github.com/docker/cli-docs-tool@${CLI_DOCS_TOOL_VERSION}
cp docs/generate/tools.go .
# update vendor
./scripts/vendor update
# build docsgen
go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
)
./scripts/vendor init
# build docsgen
go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
mkdir -p docs/yaml
set -x