Skip to content

Bundle licenses at release time#12625

Open
williammartin wants to merge 1 commit intotrunkfrom
wm-bundle-licenses-in-binaries
Open

Bundle licenses at release time#12625
williammartin wants to merge 1 commit intotrunkfrom
wm-bundle-licenses-in-binaries

Conversation

@williammartin
Copy link
Member

@williammartin williammartin commented Feb 6, 2026

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 GOOS but we started experiencing issues when GOARCH differences 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 licenses which is super annoying. This PR moves all of that to build time as a goreleaser hook, which already has GOOS and GOARCH, and then the results are bundled in the binary via embed and made available via gh 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 ./dist and use gh licenses to 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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/licenses to support both single-platform generation and verification modes
  • Added goreleaser pre-build hooks to generate licenses for each build target
  • Introduced new gh licenses command 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants