claude-plugins-official/.github/workflows/validate-licenses.yml
Noah Zweben 8326199c6e
validate-licenses: also verify LICENSE content is Apache 2.0 (#3633)
The existing check only verified that a LICENSE file exists in each
plugins/ directory. Extend it to also grep for 'Apache License' and
'Version 2.0' so that a placeholder or wrong-license file is caught
at PR time rather than silently passing.

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-03 19:19:31 -05:00

50 lines
1.4 KiB
YAML

name: Validate Plugin Licenses
on:
pull_request:
paths:
- 'plugins/**'
push:
branches: [main]
paths:
- 'plugins/**'
permissions:
contents: read
jobs:
validate-licenses:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check every plugin has an Apache 2.0 LICENSE file
run: |
set -euo pipefail
missing=()
wrong_content=()
for plugin_dir in plugins/*/; do
plugin="${plugin_dir%/}"
if [[ ! -f "$plugin/LICENSE" ]]; then
missing+=("$plugin")
elif ! grep -q "Apache License" "$plugin/LICENSE" || \
! grep -q "Version 2.0" "$plugin/LICENSE"; then
wrong_content+=("$plugin")
fi
done
if [[ "${#missing[@]}" -gt 0 ]]; then
echo "::error::The following plugins are missing a LICENSE file:"
for p in "${missing[@]}"; do
echo " - $p"
done
exit 1
fi
if [[ "${#wrong_content[@]}" -gt 0 ]]; then
echo "::error::The following plugins have a LICENSE file that does not contain Apache 2.0 text:"
for p in "${wrong_content[@]}"; do
echo " - $p"
done
exit 1
fi
echo "All $(ls -d plugins/*/ | wc -l) plugins have an Apache 2.0 LICENSE file."