forked from gitpod-io/gitpod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgo-licenses.sh
executable file
·32 lines (26 loc) · 917 Bytes
/
go-licenses.sh
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
#!/bin/sh
if [ "A$GITHUB_TOKEN" = "A" ]; then
echo "Please set the GITHUB_TOKEN env var to a personal access token. Otherwise this script won't work."
exit 1
fi
cd "$(dirname "$0")/.." || exit
out=$PWD
tmpdir=$(mktemp -d)
(cd "$tmpdir" || exit; curl -L https://github.com/mitchellh/golicense/releases/download/v0.2.0/golicense_0.2.0_linux_x86_64.tar.gz | tar xzv)
golicense="$tmpdir"/golicense
cd "components" || exit
for i in *; do
echo "trying $i"
if [ -f "$i/go.mod" ]; then
echo "building $i"
cd "$i" || exit
go build -o exec
echo "checking $i"
timeout 60 "$golicense" -plain -license=true exec >> "$out/licenses.$i.txt"
rm exec
cd - || exit
fi
done
cd ..
cat licenses.*.txt | sort | tr -s ' ' | uniq | sed -r 's/\s+/,/' | column -s , -t > "$out"/License.third-party.go.txt
echo "Output written to $out/License.third-party.go.txt"