Update Licenses #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Licenses | |
on: | |
push: | |
paths: | |
- 'go.mod' | |
- 'go.sum' | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
update-licenses: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
- name: Install go-licenses | |
run: go install github.com/google/go-licenses@latest | |
- name: Generate LICENSES.md | |
run: | | |
echo "# Licenses" > LICENSES.md | |
echo "" >> LICENSES.md | |
echo "## BirdNET-Go" >> LICENSES.md | |
echo "" >> LICENSES.md | |
echo "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International" >> LICENSES.md | |
echo "https://creativecommons.org/licenses/by-nc-sa/4.0/" >> LICENSES.md | |
echo "" >> LICENSES.md | |
echo "## Dependencies" >> LICENSES.md | |
echo "" >> LICENSES.md | |
# Get licenses excluding internal packages unless they have a LICENSE file | |
go-licenses csv github.com/tphakala/birdnet-go/... | while IFS=, read -r package license source; do | |
# Skip internal packages unless they contain a LICENSE file | |
if [[ $package == *"/internal/"* ]] && ! [[ -f "${source}/LICENSE" ]]; then | |
continue | |
fi | |
# Skip the main module | |
if [[ $package == "github.com/tphakala/birdnet-go" ]]; then | |
continue | |
fi | |
echo "### $package" >> LICENSES.md | |
echo "" >> LICENSES.md | |
echo "License: $license" >> LICENSES.md | |
echo "Source: $source" >> LICENSES.md | |
echo "" >> LICENSES.md | |
done | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: 'docs: update dependency licenses' | |
title: 'Update dependency licenses' | |
body: | | |
Automatically updated LICENSES.md with current dependency licenses. | |
This PR was created automatically by the update-licenses workflow. | |
Changes: | |
- Excluded internal packages without LICENSE files | |
- Updated dependency licenses based on go.mod changes | |
branch: update-licenses | |
delete-branch: true |