From c6e2806a10adaebc67e5cb3863d222a7e0d36b8e Mon Sep 17 00:00:00 2001 From: "Tomi P. Hakala" Date: Tue, 14 Jan 2025 19:44:43 +0200 Subject: [PATCH] feat: add GitHub Actions workflow for automatic LICENSES.md updates - Introduced a new workflow to automatically update the LICENSES.md file upon changes to go.mod and go.sum files on the main branch. - The workflow installs go-licenses, generates a comprehensive LICENSES.md file listing licenses for the project and its dependencies, and creates a pull request with the updates. - This enhancement improves documentation and compliance with licensing requirements for dependencies. --- .github/workflows/update-licenses.yml | 58 +++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/update-licenses.yml diff --git a/.github/workflows/update-licenses.yml b/.github/workflows/update-licenses.yml new file mode 100644 index 0000000..06a8c95 --- /dev/null +++ b/.github/workflows/update-licenses.yml @@ -0,0 +1,58 @@ +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 + go-licenses csv github.com/tphakala/birdnet-go | while IFS=, read -r package license source; do + 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: + 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. + branch: update-licenses + delete-branch: true \ No newline at end of file