Skip to content
SongmuPublic

About

creates CREDITS file from LICENSE files of dependencies

Resources

Stars

117 stars

Watchers

1 watching

Forks

Repository files navigation

gocredits

Test Status MIT License PkgGoDev

gocredits creates CREDITS file from LICENSE (and NOTICE) files of dependencies

Synopsis

gocredits . > CREDITS

Description

When 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.

Installation

homebrew

% brew install Songmu/tap/gocredits

go get

% go install github.com/Songmu/gocredits/cmd/gocredits@latest
% aqua g -i Songmu/gocredits

Built binaries are available on GitHub Releases. https://github.com/Songmu/gocredits/releases

GitHub Actions

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@v1

The 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 -version

The 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.

Author

Songmu

About

creates CREDITS file from LICENSE files of dependencies

Resources

Stars

117 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages