-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlicenses
More file actions
executable file
·34 lines (28 loc) · 1.32 KB
/
licenses
File metadata and controls
executable file
·34 lines (28 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# Manage go-licenses version externally for CI
if [ "$CI" != "true" ]; then
go install github.com/google/go-licenses@latest
fi
# Verify go-licenses is available
if ! command -v go-licenses &> /dev/null; then
echo "Error: go-licenses is not installed or not on PATH"
exit 1
fi
# Setup temporary directory to collect updated third-party source code
export TEMPDIR="$(mktemp -d)"
trap "rm -fr ${TEMPDIR}" EXIT
# Clear third-party source code to avoid stale content
rm -rf third-party
mkdir -p third-party
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 "Generating licenses for ${goos}..."
GOOS="${goos}" go-licenses save ./... --save_path="${TEMPDIR}/${goos}" --force || echo "Ignore warnings"
GOOS="${goos}" go-licenses report ./... --template .github/licenses.tmpl --ignore github.com/cli/cli > third-party-licenses.${goos}.md || echo "Ignore warnings"
cp -fR "${TEMPDIR}/${goos}"/* third-party/
done
echo "Licenses generated for all platforms."