license.star¶
Detect a repo's license, update its copyright year and set the license field in package manifests.
| Function | What it does |
|---|---|
find |
Finds the repo's license file. |
detect |
Identifies the license from the license file's text. |
set_year |
Extends the copyright year in the license file to year. |
set_spdx |
Sets the license field in package manifests that already have one. |
find¶
Finds the repo's license file.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
Returns: The path of the first of LICENSE, LICENSE.md, LICENSE.txt, LICENCE, COPYING and COPYING.md that exists, or None.
Example
detect¶
Identifies the license from the license file's text.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
Returns: An SPDX identifier, such as MIT or Apache-2.0, or None when
there is no license file or its text isn't recognized.
Example
Used in: license-year
set_year¶
Extends the copyright year in the license file to year.
Copyright (c) 2021 Acme becomes Copyright (c) 2021-2026 Acme, and an
existing range's end year is moved. Notices already at year and the
Apache template's [yyyy] placeholder are left alone. gh fleet has no
clock, so pass the year, for example from env.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
year |
The year to extend to, as a number or string. |
Returns: True when the file changed.
Example
Used in: license-year
set_spdx¶
Sets the license field in package manifests that already have one.
Covers license in package.json and composer.json, license in
pyproject.toml's [project] table when it is a string, and license
in Cargo.toml's [package] table.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
spdx |
The SPDX expression, such as Apache-2.0 or MIT OR Apache-2.0. |
Returns: The list of paths that changed.
Example