Google open-source compliance and licensing #
Audit, apply, and verify Google Open Source policy requirements, source code license headers with addlicense, and mandatory repository disclaimers.
Available scripts #
- scripts/apply-license.sh: Cross-platform helper that resolves
addlicensefrom$PATH,$GOBIN, or$GOPATH/bin(installing it automatically when missing), ignores generated and vendored directories safely (vendor/,node_modules/,.venv/,third_party/,_site/,*.pb.go), and supports both apply and read-only--checkmodes.
# Inspect options and usage
bash scripts/apply-license.sh --help
# Apply headers to a corporate Google Open Source repo
bash scripts/apply-license.sh -c "Google LLC" .
# Apply headers to a personal open-source repo
bash scripts/apply-license.sh -c "Jane Doe" -l apache src/
# Verify header coverage in CI without modifying files
bash scripts/apply-license.sh --check -c "Google LLC" .Flags:
-h,--help: Show usage and exit cleanly.--check: Audit existing headers and exit non-zero if any matching file lacks one.-c,--holder: Copyright holder string (defaults toGoogle LLC).-l,--license: License type:apache(default),bsd,mit, ormpl.-y,--year: Copyright year passed toaddlicense -y.-s,--spdx-only: Emit SPDX short-form identifiers only.-i,--ignore: Add extra ignore globs (repeatable).--no-default-ignores: Skip built-in build and vendor ignore patterns.
Choosing the right copyright holder #
Always inspect the root LICENSE file and existing source headers before applying or checking copyright banners:
- Corporate Google Open Source repositories (
github.com/google/*,googleapis/*,GoogleCloudPlatform/*, or Google-owned projects): use-c "Google LLC". - IARC-approved personal projects owned by a Googler: use
-c "<Author Name>"so you never overwrite personal copyright with"Google LLC", while still adding the required non-official Google product disclaimer toREADME.md.
Applying and checking headers directly with addlicense #
Install addlicense via Go when calling the binary directly:
go install github.com/google/addlicense@latestResolve addlicense across $PATH, GOBIN, and GOPATH:
ADDLICENSE="${GOBIN:-$(go env GOBIN)}"
ADDLICENSE="${ADDLICENSE:+${ADDLICENSE}/addlicense}"
ADDLICENSE="${ADDLICENSE:-$(go env GOPATH)/bin/addlicense}"
command -v addlicense >/dev/null 2>&1 && ADDLICENSE="addlicense"
# Apply Apache-2.0 headers while skipping third-party trees
"$ADDLICENSE" -c "Google LLC" -l apache \
-ignore "vendor/**" -ignore "node_modules/**" -ignore ".venv/**" .
# Audit without editing files (CI check)
"$ADDLICENSE" -check -c "Google LLC" -l apache \
-ignore "vendor/**" -ignore "node_modules/**" -ignore ".venv/**" .Common addlicense flags:
-l apache: Apache License 2.0 (standard default).-l mitor-l bsd: MIT or BSD 3-Clause header format.-s=only: Short SPDX identifier only (// SPDX-License-Identifier: Apache-2.0).-ignore "vendor/**": Exclude third-party or generated files such as*.pb.go.
Required README disclaimers #
Every repository published by Googlers or under Google Open Source that is not an official Google product needs the matching disclaimer at the bottom of README.md.
Standard non-official product disclaimer #
---
## Disclaimer
This is not an officially supported Google product.Experimental or educational project disclaimer #
---
## Disclaimer
This is not an officially supported Google product. It is an experimental project created for educational and development purposes.Pre-release compliance checklist #
- License header coverage: Run
scripts/apply-license.sh --check(oraddlicense -check) across.go,.py,.ts,.js,.rs,.c,.cpp,.sh, and.protofiles, confirming generated and third-party files stay excluded. - Root
LICENSEfile: Confirm an unmodified text copy of the chosen license exists at the repository root. - Copyright holder accuracy: Verify the header holder matches corporate (
Google LLC) or personal ownership rules. - Non-official product disclaimer: Confirm the
## Disclaimersection appears at the bottom ofREADME.md. - Zero internal leaks: Verify there are no internal URLs, internal bug trackers, corporate credentials, or non-public codenames.
References #
- License header formats: Comment styles for Apache 2.0, MIT, BSD 3-Clause, and SPDX short identifiers.
- Disclaimer templates: Standard, sample-code, experimental, and maintenance notices.
