forked from golang/vscode-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools/license.sh: script to generate LICENSE for product
Runs from the project root directory. That will generate LICENSE.prod, which should replace LICENSE in the released product. This script uses `yarn licenses generate-disclaimer`, so this cl adds the dev dependency on yarn. We call this during the release process. And delete thirdpartynotices.txt - that is stale and was never updated after the first introduction. The autogenerated LICENSE file with tools/license.sh includes the license for json-rpc2. Change-Id: I5c0869bc9a86aac1769441a663229eb4c5141b73 GitHub-Last-Rev: b561d4c GitHub-Pull-Request: golang#240 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/238860 Reviewed-by: Rebecca Stambler <[email protected]>
- Loading branch information
Showing
4 changed files
with
78 additions
and
36 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2020 The Go Authors. All rights reserved. | ||
# Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
set -euo pipefail | ||
|
||
root_dir() { | ||
local script_name="${0}" | ||
local script_dir=$(dirname "${script_name}") | ||
local parent_dir=$(cd "${script_dir}/.." && pwd) | ||
echo "${parent_dir}" | ||
} | ||
|
||
ROOT="$(root_dir)" | ||
cd "${ROOT}" # always run from the root directory. | ||
|
||
WORKTREE="$(mktemp -d)" | ||
BRANCH="license-gen-$(date +%Y%m%d%H%M%S)" | ||
|
||
git fetch | ||
git worktree add --track -b "${BRANCH}" "${WORKTREE}" origin/master | ||
|
||
cd "${WORKTREE}" | ||
export GIT_GOFMT_HOOK=off | ||
|
||
YARN="${ROOT}/node_modules/.bin/yarn" | ||
|
||
ALL_LICENSES=$( | ||
$YARN licenses list --json --no-progress 2>/dev/null| | ||
jq 'select(.type == "table") | .data.body | map( {name: .[0], version: .[1], license: .[2], url: .[3], verndor: .[4], vendorName: .[5]} )') | ||
|
||
NG=$(echo "${ALL_LICENSES}" | jq ' | ||
{ | ||
"Apache-2.0": 1, | ||
"BSD-2-Clause": 1, | ||
"BSD-3-Clause": 1, | ||
"ISC": 1, | ||
"MIT": 1, | ||
"Unlicense": 1, | ||
"0BSD": 1, | ||
"(Unlicense OR Apache-2.0)": 1, | ||
} as $allowed_licenses | | ||
{ | ||
"[email protected]": 1, | ||
} as $allow_list | | ||
.[] | select(.license | in($allowed_licenses) | not) | ||
| select((.name+"@"+.version) | in($allow_list) | not) ') | ||
|
||
if [ -z "${NG}" ]; | ||
then | ||
echo "PASSED license check" | ||
else | ||
echo "FAILED license check. The following dependencies need manual check: ${NG}" && | ||
echo "WORKTREE=${WORKTREE}" && | ||
exit 1 | ||
fi | ||
|
||
LICENSEFILE="LICENSE.prod" | ||
cat LICENSE > "${LICENSEFILE}" | ||
printf "\n\n" >> "${LICENSEFILE}" | ||
"${YARN}" licenses generate-disclaimer --prod >> "${LICENSEFILE}" | ||
|
||
if [[ -f thirdpartynotices.txt ]] | ||
then | ||
printf "\n" >> "${LICENSEFILE}" | ||
cat thirdpartynotices.txt >> "${LICENSEFILE}" | ||
fi | ||
|
||
cd - && mv "${WORKTREE}/${LICENSEFILE}" . && git worktree remove "${WORKTREE}" -f |