From acb4d8f4f22b810aa36724105c3b28ce11444e17 Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Mon, 16 Nov 2026 15:57:44 -0300 Subject: [PATCH] build(release): ship licence notices with the binary and image The Go CLI ports github.com/devcontainers/cli and carries its test fixtures and updateUID.Dockerfile, which are MIT (Copyright (c) Microsoft Corporation); NOTICE now keeps that notice. The modules the binary links (MIT, BSD, Apache) ask that their notice go with every copy, so task release:notices writes THIRD_PARTY_NOTICES from go-licenses (pinned in versions.yaml) plus Go's own licence, and the archives and the image ship LICENSE.txt, NOTICE and THIRD_PARTY_NOTICES. release:smoke fails a release without them. LICENSE.txt's copyright line names The spin-stack Authors, as the other spin-stack repositories will. Co-Authored-By: Claude Opus 5.5 --- .gitignore | 1 + .goreleaser.yml | 11 +++++++ Dockerfile | 2 ++ LICENSE.txt | 2 +- NOTICE | 47 ++++++++++++++++++++++++++++++ Taskfile.yml | 55 ++++++++++++++++++++++++++++++++++- hack/third-party-notices.tmpl | 12 ++++++++ versions.yaml | 9 ++++++ 8 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 NOTICE create mode 100644 hack/third-party-notices.tmpl diff --git a/.gitignore b/.gitignore index f85c053..1fb6656 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ coverage.xml .claude/ .task/ +/THIRD_PARTY_NOTICES diff --git a/.goreleaser.yml b/.goreleaser.yml index 253fa5c..f63b8c2 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -9,6 +9,8 @@ snapshot: before: hooks: - go mod tidy + # What archives: and dockers_v2: ship beside the binary: the licences of what it links. + - go tool task release:notices # NOTE: `go test ./...` is intentionally NOT run here. It would sweep the # Docker/network parity suites and reference/node_modules. Gating lives in # the CI / tag workflow (.github/workflows/release.yml), not the release hook. @@ -34,6 +36,11 @@ archives: - id: default formats: [tar.gz] name_template: "devcontainer_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + # A copy of the binary carries the notices its licences and Microsoft's MIT ask for. + files: + - LICENSE.txt + - NOTICE + - THIRD_PARTY_NOTICES checksum: name_template: "checksums.txt" @@ -60,6 +67,10 @@ dockers_v2: ids: - devcontainer dockerfile: Dockerfile + extra_files: + - LICENSE.txt + - NOTICE + - THIRD_PARTY_NOTICES images: - ghcr.io/spin-stack/devcontainer-cli # Only the immutable, versioned tag here. `latest` is a moving tag, which is diff --git a/Dockerfile b/Dockerfile index 50cf7ec..a55533c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,5 +43,7 @@ LABEL org.opencontainers.image.revision="${REVISION}" USER nonroot:nonroot COPY ${TARGETPLATFORM}/devcontainer /devcontainer +# The image is a copy of the binary, so the notices its licences ask for go with it. +COPY LICENSE.txt NOTICE THIRD_PARTY_NOTICES /usr/share/doc/devcontainer-cli/ ENTRYPOINT ["/devcontainer"] diff --git a/LICENSE.txt b/LICENSE.txt index 007f0e1..47c64b8 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2026 spin-stack + Copyright The spin-stack Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..081b4af --- /dev/null +++ b/NOTICE @@ -0,0 +1,47 @@ +devcontainer-cli +Copyright The spin-stack Authors + +Licensed under the Apache License, Version 2.0; see LICENSE.txt. + +This product is a Go implementation of the Dev Container CLI, +https://github.com/devcontainers/cli, written to behave as that CLI does and +validated against it. It contains material taken from that project, which is +under the MIT License below: + + - the test fixtures under src/test/configs/; + - internal/docker/updateUID.Dockerfile, which the binary embeds; + - the Go code that ports that CLI's behaviour (configuration merging, + lifecycle order, Feature and Template handling, output and errors). + +The Apache-2.0 licence does not take away the MIT notice below from that +material: a copy of it, or of a substantial portion of it, carries the notice. + +THIRD_PARTY_NOTICES, shipped beside the binary in a release, carries the +licence of each Go module compiled into the binary. + +-------------------------------------------------------------------------------- +github.com/devcontainers/cli +-------------------------------------------------------------------------------- + +MIT License + +Copyright (c) Microsoft Corporation. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Taskfile.yml b/Taskfile.yml index 25f8877..4abf093 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -24,6 +24,8 @@ vars: COVER_DATA: artifacts/coverage/data # The image GoReleaser publishes (.goreleaser.yml's dockers), tagged with the version. IMAGE: ghcr.io/spin-stack/devcontainer-cli + # What a release archive and the image carry beside the binary (.goreleaser.yml, Dockerfile). + NOTICES: LICENSE.txt NOTICE THIRD_PARTY_NOTICES tasks: default: @@ -419,6 +421,28 @@ tasks: cmds: - echo "DISTROLESS_IMAGE=$(versions ref distroless)" >> "$GITHUB_ENV" + # The MIT, BSD and Apache licences of what the binary links ask that their notice go with every + # copy, a compiled one too; GoReleaser runs this before it packs the archives and the image. + release:notices: + desc: Write THIRD_PARTY_NOTICES, the licence of Go and of each module compiled into the binary + cmds: + - | + set -euo pipefail + out=$(mktemp) + trap 'rm -f "$out"' EXIT + { + printf '%s\n' "Third-party software compiled into the devcontainer binary, each with its licence." \ + "devcontainer-cli's own licence is LICENSE.txt; NOTICE names what it takes from github.com/devcontainers/cli." + printf '\n%s\n%s\n%s\n\n' "================================================================================" \ + "Go standard library and runtime $(go env GOVERSION)" \ + "================================================================================" + cat "$(go env GOROOT)/LICENSE" + go run "github.com/google/go-licenses/v2@$(versions version go-licenses)" report ./cmd/devcontainer \ + --ignore {{.MODULE}} --template hack/third-party-notices.tmpl + } > "$out" + mv "$out" THIRD_PARTY_NOTICES + trap - EXIT + # The release workflow's own steps. What only the workflow knows - the dispatch input, the # prepare job's outputs, the published digest - comes in the environment. release:resolve: @@ -438,7 +462,7 @@ tasks: git push origin "$RELEASE_TAG" release:smoke: - desc: Check the published image of RELEASE_VERSION reports that version + desc: Check the published image of RELEASE_VERSION reports that version, and it and dist's archives carry the licence notices cmds: - | set -euo pipefail @@ -446,6 +470,35 @@ tasks: GOT="$(docker run --rm "$IMAGE" --version)" echo "image reported version: $GOT (expected: $RELEASE_VERSION)" test "$GOT" = "$RELEASE_VERSION" + - task: release:smoke:archives + - task: release:smoke:image-notices + + release:smoke:archives: + internal: true + cmds: + - | + set -euo pipefail + set -- dist/*.tar.gz + test -e "$1" || { echo "no archive in dist/" >&2; exit 1; } + for a in "$@"; do + list=$(tar -tzf "$a") + for f in {{.NOTICES}}; do + grep -qx "$f" <<<"$list" || { echo "$a: no $f" >&2; exit 1; } + done + done + + # The image has no shell, so the files are read from a created, never started, container. + release:smoke:image-notices: + internal: true + cmds: + - | + set -euo pipefail + IMAGE="{{.IMAGE}}:$RELEASE_VERSION" + c=$(docker create "$IMAGE") + trap 'docker rm -f "$c" >/dev/null' EXIT + for f in {{.NOTICES}}; do + docker cp "$c:/usr/share/doc/devcontainer-cli/$f" - | tar -t >/dev/null || { echo "$IMAGE: no $f" >&2; exit 1; } + done release:digest: desc: "Record the digest of the published image of RELEASE_VERSION (digest= to $GITHUB_OUTPUT, and the job summary)" diff --git a/hack/third-party-notices.tmpl b/hack/third-party-notices.tmpl new file mode 100644 index 0000000..e349398 --- /dev/null +++ b/hack/third-party-notices.tmpl @@ -0,0 +1,12 @@ +{{- /* go-licenses lists a module once per licence it finds in the file, so a module repeats when its file holds two; $prev prints each module's text once. */ -}} +{{- $prev := "" -}} +{{- range . -}} +{{- if ne .Name $prev }} +================================================================================ +{{ .Name }} {{ .Version }} +================================================================================ + +{{ .LicenseText }} +{{ end -}} +{{- $prev = .Name -}} +{{- end -}} diff --git a/versions.yaml b/versions.yaml index 6623d20..6e7da89 100644 --- a/versions.yaml +++ b/versions.yaml @@ -48,3 +48,12 @@ note: >- The Task `go tool task` runs (go-tools' cmd/task), for every platform a person or a runner works on: no repository compiles it. + +- name: go-licenses + kind: module + source: github.com/google/go-licenses/v2 + version: v2.0.1 + track: github-release https://github.com/google/go-licenses + note: >- + task release:notices, which writes THIRD_PARTY_NOTICES for the release archives and image. + A bump is checked by task release:notices and the archive listing of task release --snapshot.