Add license compliance to release archives
All checks were successful
CI / test (pull_request) Successful in 14s

This commit is contained in:
2026-08-13 12:56:31 +09:00
parent b06bd0abcd
commit 4519065a15
6 changed files with 858 additions and 1 deletions

View File

@@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
temp_dir="$(mktemp -d)"
trap 'rm -rf "$temp_dir"' EXIT
go_license="$(go env GOROOT)/LICENSE"
if [ ! -f "$go_license" ] && [ -f /usr/share/licenses/go/LICENSE ]; then
go_license=/usr/share/licenses/go/LICENSE
fi
if [ ! -f "$go_license" ]; then
echo "Go license file was not found" >&2
exit 1
fi
cat >"$temp_dir/template.txt" <<'EOF'
{{ range . }}================================================================================
Package: {{ .Name }}
License: {{ .LicenseName }}
Source: {{ .LicenseURL }}
{{ .LicenseText }}
{{ end }}
EOF
{
cat <<'EOF'
THIRD-PARTY SOFTWARE NOTICES
This file contains license notices for third-party software included in the distributed binary.
================================================================================
Package: Go standard library
License: BSD-3-Clause
Source: https://go.dev/LICENSE
EOF
cat "$go_license"
printf '\n'
cd "$repo_root"
go run github.com/google/go-licenses/v2@v2.0.1 report ./cmd/dataxl \
--ignore=git.rumginger.org/agent/dataxl \
--template="$temp_dir/template.txt"
} >"$temp_dir/THIRD_PARTY_LICENSES.txt"
awk '
{ lines[NR] = $0 }
$0 !~ /^[[:space:]]*$/ { last_content_line = NR }
END {
for (line_number = 1; line_number <= last_content_line; line_number++) {
print lines[line_number]
}
}
' "$temp_dir/THIRD_PARTY_LICENSES.txt" >"$temp_dir/THIRD_PARTY_LICENSES.normalized.txt"
mv "$temp_dir/THIRD_PARTY_LICENSES.normalized.txt" "$repo_root/THIRD_PARTY_LICENSES.txt"