Bundle licenses at release time#12625
Bundle licenses at release time#12625williammartin merged 3 commits intotrunkcli/cli:trunkfrom wm-bundle-licenses-in-binariescli/cli:wm-bundle-licenses-in-binariesCopy head branch name to clipboard
Conversation
e76ba52 to
6c83778
Compare
6c83778 to
03ba23c
Compare
03ba23c to
9c844a7
Compare
There was a problem hiding this comment.
Pull request overview
This PR modernizes the license compliance workflow by moving license generation from development time to build time. License information is now generated as a goreleaser pre-build hook for each platform and embedded into the binary via go:embed, making it accessible through a new gh licenses command. This eliminates the need to commit platform-specific license files to the repository and removes the requirement to run make licenses after every dependency update.
Changes:
- Removed all committed third-party license files and reports from the repository
- Modified
script/licensesto support both single-platform generation and verification modes - Added goreleaser pre-build hooks to generate licenses for each build target
- Introduced new
gh licensescommand to display embedded license information
Reviewed changes
Copilot reviewed 207 out of 207 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| third-party/*/LICENSE | Removed all committed third-party license files |
| script/licenses-check | Removed standalone license check script |
| script/licenses | Refactored to support both build-time generation and CI verification |
| pkg/cmd/root/root.go | Added licenses command to root command |
| pkg/cmd/licenses/licenses.go | New command to display embedded license information |
| internal/licenses/licenses.go | Core logic for embedding and formatting license content |
| internal/licenses/licenses_test.go | Unit tests for license content generation |
| internal/licenses/embed/* | Placeholder files for embedded license data |
| docs/license-compliance.md | Updated documentation for new workflow |
| Makefile | Updated license targets to use new script interface |
| .goreleaser.yml | Added pre-build hooks to generate licenses |
| .github/workflows/lint.yml | Updated CI to verify license generation |
| .github/secret_scanning.yml | Removed exclusions for deleted license files |
| .github/licenses.tmpl | Simplified template for embedded report |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9c844a7 to
b510389
Compare
.github/workflows/lint.yml
Outdated
| # which causes go-licenses to raise "Package ... does not have module info" errors. | ||
| # For more information, https://github.com/google/go-licenses/issues/244#issuecomment-1885098633 | ||
| # | ||
| # go-licenses has been pinned for automation use. |
There was a problem hiding this comment.
I don't think this comment is valid anymore
| # go-licenses has been pinned for automation use. |
.github/secret_scanning.yml
Outdated
| paths-ignore: | ||
| - 'third-party/**' | ||
| - 'third-party-licenses.*.md' | ||
| paths-ignore: [] |
There was a problem hiding this comment.
Could just delete this file, probably.
Not sure it's practical, but maybe we could look at compressing the embedded licenses and decompressing them at runtime? |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Description
We currently handle our license compliance by producing reports, and including licenses and NOTICES in our source code. We have a script that does this per
GOOSbut we started experiencing issues whenGOARCHdifferences could result in failures on CI not noticed locally. We made an attempt to provide a matrix of these options but it gets pretty annoying. We'd also need to keep it updated as release targets change.Separately, we also have this issue where every dependabot PR requires
make licenseswhich is super annoying. This PR moves all of that to build time as a goreleaser hook, which already hasGOOSandGOARCH, and then the results are bundled in the binary viaembedand made available viagh licenses.I don't think we have any obligation to solve for other people building/distributing an artifact, so the default embed has some help text.
Reviewer Notes
You can run
./script/release --local --platform <platform>to build under./distand usegh licensesto check the output.You can also get a staging release from here: https://github.com/cli/cli/actions/runs/21755383986
It maybe adds about 1MB to the size of the binary, seems fast enough to run
gh licenses