diff options
| author | Abner C. Paula <abner.cordeiro@ossystems.com.br> | 2024-12-05 08:50:26 -0300 |
|---|---|---|
| committer | Abner C. Paula <abner.cordeiro@ossystems.com.br> | 2024-12-05 10:32:47 -0300 |
| commit | 77f6565f4ac5d9a57dc49abafa04dca07cb2979a (patch) | |
| tree | cab785df50d8ba5f7658ddf38de7e90327a3515c | |
| parent | 80efea91fd5de264a7091b3223ecd595b25ff92e (diff) | |
| download | meta-freescale-77f6565f4ac5d9a57dc49abafa04dca07cb2979a.tar.gz | |
Add workflow to automatically update LICENSE file with recipe licenses
Originally from meta-freescale-3rdparty.
Signed-off-by: Abner C. Paula <abner.cordeiro@ossystems.com.br>
| -rw-r--r-- | .github/workflows/update-license-file.yml | 35 | ||||
| -rwxr-xr-x | scripts/generate-license-file | 18 |
2 files changed, 53 insertions, 0 deletions
diff --git a/.github/workflows/update-license-file.yml b/.github/workflows/update-license-file.yml new file mode 100644 index 000000000..5b62ec119 --- /dev/null +++ b/.github/workflows/update-license-file.yml | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | name: Update LICENSE file | ||
| 2 | |||
| 3 | on: | ||
| 4 | push: | ||
| 5 | paths: | ||
| 6 | - "**/*.bb" | ||
| 7 | - "**/*.inc" | ||
| 8 | schedule: | ||
| 9 | - cron: "0 0 * * *" # Runs daily at midnight | ||
| 10 | workflow_dispatch: # Allows manual run | ||
| 11 | |||
| 12 | jobs: | ||
| 13 | update-license: | ||
| 14 | runs-on: ubuntu-latest | ||
| 15 | |||
| 16 | steps: | ||
| 17 | - name: Checkout repository | ||
| 18 | uses: actions/checkout@v3 | ||
| 19 | |||
| 20 | - name: Run license generation script | ||
| 21 | run: | | ||
| 22 | ./scripts/generate-license-file | ||
| 23 | |||
| 24 | - name: Commit and push LICENSE file | ||
| 25 | run: | | ||
| 26 | git config --local user.name "github-actions[bot]" | ||
| 27 | git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
| 28 | git add LICENSE | ||
| 29 | if ! git diff-index --quiet HEAD; then | ||
| 30 | git commit -m "Auto-update LICENSE file with current recipe licenses" | ||
| 31 | git push | ||
| 32 | fi | ||
| 33 | |||
| 34 | env: | ||
| 35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
diff --git a/scripts/generate-license-file b/scripts/generate-license-file new file mode 100755 index 000000000..b6d43cd9f --- /dev/null +++ b/scripts/generate-license-file | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | # Create or clear the LICENSE file | ||
| 4 | echo "# License Information" > LICENSE | ||
| 5 | echo "" >> LICENSE | ||
| 6 | echo "This file lists all licenses used by recipes in the meta-freescale-3rdparty layer." >> LICENSE | ||
| 7 | echo "" >> LICENSE | ||
| 8 | |||
| 9 | # Find all .bb and .inc files and extract license information | ||
| 10 | find . -type f \( -name "*.bb" -o -name "*.inc" \) | while read -r file; do | ||
| 11 | # Extract the license line from each recipe file, if it exists | ||
| 12 | license_line=$(grep -i "^LICENSE" "$file") | ||
| 13 | if [ -n "$license_line" ]; then | ||
| 14 | echo "$file: $license_line" >> LICENSE | ||
| 15 | fi | ||
| 16 | done | ||
| 17 | |||
| 18 | echo "LICENSE file has been generated and updated with current recipe licenses." | ||
