Prototype licensing workflow

This commit is contained in:
Andy Feller 2024-08-20 23:42:57 -04:00
parent 95a2f95f75
commit 36d622ed48
2 changed files with 53 additions and 0 deletions

13
.github/licenses.tmpl vendored Normal file
View file

@ -0,0 +1,13 @@
# GitHub CLI dependencies
The following open source dependencies are used to build the [GitHub CLI _(`gh`)_](https://github.com/cli/cli).
## Go Packages
Some packages may only be included on certain architectures or operating systems.
| **Module** | **Version** | **License** | **License File** | **Package Docs**
| ---------- | ----------- | ----------- | ---------------- | ----------------
{{- range . }}
| {{ .Name }} | {{ .Version }} | {{ .LicenseName }} | {{ .LicenseURL }} | [pkg.go.dev](https://pkg.go.dev/{{ .Name }}@{{ .Version }})
{{- end }}

40
.github/workflows/licenses.yml vendored Normal file
View file

@ -0,0 +1,40 @@
name: Licensing
on:
push:
tags:
- "v*"
env:
GOPACKAGE: github.com/cli/cli/v2
LICENSE_DIR: licenses
LICENSE_ARCHIVE: licenses.tgz
jobs:
go-licenses:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Generate Go license notices
working-directory: ${{ env.LICENSE_DIR }}
run: |
go install github.com/google/go-licenses@latest
go-licenses report "$GOPACKAGE" --template=../.github/licenses.tmpl --stderrthreshold=ERROR --logtostderr=false > README.md
go-licenses save "$GOPACKAGE" --stderrthreshold=ERROR --logtostderr=false
- name: Upload Go license notices
run: |
tar czf "$LICENSE_ARCHIVE" "$LICENSE_DIR"
gh release upload "$GITHUB_REF_NAME" --clobber -- "$LICENSE_ARCHIVE"
if gh release view "$GITHUB_REF_NAME" >/dev/null; then
echo "uploading assets to an existing release..."
gh release upload "$GITHUB_REF_NAME" --clobber -- "$LICENSE_ARCHIVE"
else
echo "cannot upload as something else should create the release first..."
exit 1
fi