diff --git a/.gitignore b/.gitignore index 89395b7cd..0e1950011 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ output schema/validate code-of-conduct.md +version.md diff --git a/.tool/version-doc.go b/.tool/version-doc.go new file mode 100644 index 000000000..f36bfe4c3 --- /dev/null +++ b/.tool/version-doc.go @@ -0,0 +1,25 @@ +// +build ignore + +package main + +import ( + "fmt" + "html/template" + "os" + + "github.com/opencontainers/runtime-spec/specs-go" +) + +var markdownTemplateString = ` + +**Specification Version:** *{{.}}* + +` + +var markdownTemplate = template.Must(template.New("markdown").Parse(markdownTemplateString)) + +func main() { + if err := markdownTemplate.Execute(os.Stdout, specs.Version); err != nil { + fmt.Fprintln(os.Stderr, err) + } +} diff --git a/Makefile b/Makefile index e270ca0bd..69724b96a 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ DOCKER ?= $(shell which docker) # These docs are in an order that determines how they show up in the PDF/HTML docs. DOC_FILES := \ + version.md \ README.md \ code-of-conduct.md \ principles.md \ @@ -45,6 +46,9 @@ output/docs.html: $(DOC_FILES) code-of-conduct.md: curl -o $@ https://raw.githubusercontent.com/opencontainers/tob/d2f9d68c1332870e40693fe077d311e0742bc73d/code-of-conduct.md +version.md: ./specs-go/version.go + go run ./.tool/version-doc.go > $@ + HOST_GOLANG_VERSION = $(shell go version | cut -d ' ' -f3 | cut -c 3-) # this variable is used like a function. First arg is the minimum version, Second arg is the version to be checked. ALLOWED_GO_VERSION = $(shell test '$(shell /bin/echo -e "$(1)\n$(2)" | sort -V | head -n1)' == '$(1)' && echo 'true')