Detect license names and types for Python PyPI packages. Identify license types for given license names obtained by third-party tools. Great coverage of free/libre and open source licenses of all types: public domain, permissive, copyleft.
Supported formats:
requirements.txt
(detect license name and license type)Based on pip-license-check command-line tool.
jobs:
license_check:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.6'
- name: Get explicit and transitive dependencies
run: |
pip install -r requirements.txt
pip freeze > requirements-all.txt
- name: Check python
id: license_check_report
uses: pilosus/action-pip-license-checker@v2
with:
requirements: 'requirements-all.txt'
fail: 'Copyleft'
exclude: '(?i)^(pylint|aio[-_]*).*'
- name: Print report
if: ${{ always() }}
run: echo "${{ steps.license_check_report.outputs.report }}"
license-checker
packagejobs:
license_check:
runs-on: ubuntu-lastest
steps:
...
- name: Check license-checker CSV file without headers
id: license_check_report
uses: pilosus/action-pip-license-checker@v2
with:
external: 'npm-license-checker.csv'
external-format: 'csv'
external-options: '{:skip-header true}'
fail: 'StrongCopyleft,NetworkCopyleft,Other,Error'
fails-only: true
exclude: 'your-company-name.*'
exclude-license: '(?i)copyright'
totals: true
verbose: 1
github-token: ${{ secrets.OAUTH_TOKEN_GITHUB }}
...
gradle-license-plugin
packagejobs:
license_check:
runs-on: ubuntu-latest
steps:
...
- name: Check gradle-license-plugin JSON file
id: license_check_report
uses: pilosus/action-pip-license-checker@v2
with:
external: 'gradle-license-plugin.json'
external-format: 'gradle'
external-options: '{:fully-qualified-names false}'
fail: 'StrongCopyleft,NetworkCopyleft,Other,Error'
fails-only: true
exclude: 'your-company-name.*'
totals: true
...
cocoapods-acknowledgements
packagejobs:
license_check:
runs-on: ubuntu-latest
steps:
...
- name: Check cocoapods-acknowledgements Plist file
id: license_check_report
uses: pilosus/action-pip-license-checker@v2
with:
external: 'cocoapods-acknowledgements.plist'
external-format: 'cocoapods'
external-options: '{:skip-header true :skip-footer true}'
fail: 'StrongCopyleft,NetworkCopyleft,Other,Error'
fails-only: true
exclude: 'your-company-name.*'
totals: true
...
By using the report-format
input field and a third-party
actions/upload-artifact
action you can save the report as a file and download it. In the
following example the license check report is generated in
json-pretty
format and saved as a GitHub workflow artifact:
jobs:
license_check:
runs-on: ubuntu-latest
steps:
...
- name: Check licenses
id: license_check_report
uses: pilosus/action-pip-license-checker@5b5956a1093c68ebac6ff53c8427790d04ee5c26
with:
external: 'licenses.csv'
external-format: 'csv'
external-options: '{:skip-header false :package-column-index 0 :license-column-index 2}'
report-format: 'json-pretty'
formatter: '%-65s %-65s %-20s %-40s'
totals: true
headers: true
fail: 'StrongCopyleft,NetworkCopyleft,Other,Error'
verbose: 1
- name: Save report
if: ${{ always() }}
run: echo "${{ steps.license_check_report.outputs.report }}" > license-report.json
- name: Upload artifact
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: license-report
path: license-report.json
Then the report can be downloaded as an archived artifact.
See the documentation.
All the inputs correspond with pip-license-checker
's
options.
requirements
Path to requirements file, e.g. requirements.txt
. Separate multiple files with comma: file1.txt,file2.txt,file3.txt
.
external
Path to an external file. Separate multiple files with comma: file1.csv,file2.csv,file3.csv
.
Used to check license types for the list of given packages with their licenses.
Allows to check license types for JavaScript, Java or any other dependencies with known licenses in one of the supported file formats.
external-format
External file format: csv
, cocoapods
, gradle
, etc.
See the full list of supported formats and their documentation here.
external-options
String of options in EDN format.
See the documentation for more details.
fail
Return non-zero exit code if license type provided via the input is found. Use one of the following values:
WeakCopyleft
StrongCopyleft
NetworkCopyleft
Copyleft
(includes all of above types of copyleft)Permissive
Other
(EULA, other non standard licenses)Error
(package or its license not found)Separate multiple license types with comma: Copyleft,Other,Error
.
fails-only
Print only packages of license types specified with fail
input.
exclude
Regular expression (PCRE) to exclude matching packages from the check.
exclude-license
Regular expression (PCRE) to exclude matching license names from the check.
pre
Include pre-release and development versions.
totals
Print totals for license types found. Totals appended after the detailed list of the packages.
totals-only
Print only totals for license types found, do not include the detailed list of the packages checked.
headers
Print table headers for detailed list of the packages.
report-format
Report format: stdout
(default), json
, json-pretty
, csv
.
formatter
Printf-style formatter string for report formatting. Default value is %-35s %-55s %-30s
.
github-token
GitHub OAuth Token to increase rate-limits when requesting GitHub API. Recommended to keep a token as a GitHub secret.
verbose
Output verbosity level:
false
, default) - no verbositytrue
) - errors onlyLevels 1 and higher add a Misc
column to a report table.
report
License check report.
See Contributing guide.
Software is provided on an "as-is" basis and makes no warranties regarding any information provided through it, and disclaims liability for damages resulting from using it. Using the software does not constitute legal advice nor does it create an attorney-client relationship.