cli/script/licenses-check
Andy Feller bd24865076 Adopt license compliance scripts into workflows, docs
This commit introduces the use of `go-licenses` within CI/CD and manual processes for generating / updating the license information used by GitHub CLI including the code required by license to be redistributed.

During GitHub CLI pull requests, the `lint` workflow will notify users if this information is not updated.
2025-05-30 12:46:51 -04:00

21 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
go install github.com/google/go-licenses@latest
for goos in linux darwin windows ; do
# Note: we ignore warnings because we want the command to succeed, however the output should be checked
# for any new warnings, and potentially we may need to add license information.
#
# Normally these warnings are packages containing non go code, which may or may not require explicit attribution,
# depending on the license.
echo "Checking licenses for ${goos}..."
GOOS="${goos}" go-licenses report ./... --template .github/licenses.tmpl --ignore github.com/cli/cli > third-party-licenses.${goos}.copy.md || echo "Ignore warnings"
if ! diff -s third-party-licenses.${goos}.copy.md third-party-licenses.${goos}.md; then
echo "::error title=License check failed::Please update the license files by running \`script/licenses\` and committing the output."
rm -f third-party-licenses.${goos}.copy.md
exit 1
fi
rm -f third-party-licenses.${goos}.copy.md
done
echo "License check passed for all platforms."