gocredits creates CREDITS file from LICENSE (and NOTICE) files of dependencies
gocredits . > CREDITSWhen distributing built executable in Go, we need to include LICENSE of the dependent libraries into the package, so gocredits bundle them together as a CREDITS file.
If a dependency also ships a NOTICE file (NOTICE, NOTICE.txt or NOTICE.md), as
section 4(d) of the Apache License 2.0 asks redistributors to include, gocredits puts it
right after that dependency's LICENSE. The output for dependencies without a NOTICE file
does not change.
To use gocredits, we should use go modules for dependency management.
% brew install Songmu/tap/gocredits% go install github.com/Songmu/gocredits/cmd/gocredits@latest% aqua g -i Songmu/gocreditsBuilt binaries are available on GitHub Releases. https://github.com/Songmu/gocredits/releases
The action installs and runs gocredits, overwriting CREDITS in the repository
root:
permissions:
contents: read
steps:
- uses: actions/checkout@v7
- id: gocredits
uses: Songmu/gocredits@v1The module directory, missing-license behavior, and output format can be configured:
- uses: Songmu/gocredits@v1
with:
directory: ./path/to/module
skip-missing: true
format: |
{{range .Licenses}}{{.Name}}
{{end}}By default, the action runs gocredits after installing it. To install it
without generating CREDITS, set run to false. The installed command is
available to subsequent steps:
- uses: Songmu/gocredits@v1
with:
run: false
- run: gocredits -versionThe action outputs the absolute credits path and a changed value indicating
whether the file contents changed when run is true. Both outputs are empty
when run is false. The action does not commit or push the generated file.
The contents: read permission is required by the checkout step.