Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/scripts/go-licenses.sh
2486 views
1
#!/bin/sh
2
3
if [ "A$GITHUB_TOKEN" = "A" ]; then
4
echo "Please set the GITHUB_TOKEN env var to a personal access token. Otherwise this script won't work."
5
exit 1
6
fi
7
8
cd "$(dirname "$0")/.." || exit
9
out=$PWD
10
11
tmpdir=$(mktemp -d)
12
(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)
13
golicense="$tmpdir"/golicense
14
15
cd "components" || exit
16
for i in *; do
17
echo "trying $i"
18
if [ -f "$i/go.mod" ]; then
19
echo "building $i"
20
cd "$i" || exit
21
go build -o exec
22
23
echo "checking $i"
24
timeout 60 "$golicense" -plain -license=true exec >> "$out/licenses.$i.txt"
25
rm exec
26
cd - || exit
27
fi
28
done
29
cd ..
30
31
cat licenses.*.txt | sort | tr -s ' ' | uniq | sed -r 's/\s+/,/' | column -s , -t > "$out"/License.third-party.go.txt
32
echo "Output written to $out/License.third-party.go.txt"
33
34