diff --git a/.github/templates/NOTICE.txt.tmpl b/.github/templates/NOTICE.txt.tmpl new file mode 100644 index 000000000..11c7a0ce2 --- /dev/null +++ b/.github/templates/NOTICE.txt.tmpl @@ -0,0 +1,29 @@ +{{- define "depInfo" -}} +{{- range $i, $dep := . }} +{{ "-" | line }} +Module : {{ $dep.Name }} +Version : {{ $dep.Version }} +Time : {{ $dep.VersionTime }} +Licence : {{ $dep.LicenceType }} + +{{ $dep | licenceText }} +{{ end }} +{{- end -}} + +Copyright 2023-{{ currentYear }} Quesma Inc + +This product includes software developed by The Apache Software +Foundation (http://www.apache.org/). + +{{ "=" | line }} +Third party libraries used by the quesma project +{{ "=" | line }} + +{{ template "depInfo" .Direct }} + +{{ if .Indirect }} +{{ "=" | line }} +Indirect dependencies + +{{ template "depInfo" .Indirect }} +{{ end }} diff --git a/.github/templates/dependencies.asciidoc.tmpl b/.github/templates/dependencies.asciidoc.tmpl new file mode 100644 index 000000000..98cd3bdd7 --- /dev/null +++ b/.github/templates/dependencies.asciidoc.tmpl @@ -0,0 +1,51 @@ +{{- define "depRow" -}} +{{- range $i, $dep := . }} +| link:{{ $dep.URL }}[$${{ $dep.Name }}$$] | {{ $dep.Version }} | {{ $dep.LicenceType }} +{{- end }} +{{- end -}} +// Generated documentation. Please do not edit. +:page_id: dependencies +ifdef::env-github[] +**** +link:https://www.elastic.co/guide/en/cloud-on-k8s/master/k8s-{page_id}.html[View this document on the Elastic website] +**** +endif::[] + +[id="{p}-{page_id}"] += Third-party dependencies + +This page lists the third-party dependencies used to build {n}. + +[float] +[id="{p}-dependencies-direct"] +== Direct dependencies + +[options="header"] +|=== +| Name | Version | Licence +{{ template "depRow" .Direct }} +|=== + +{{ if .Indirect }} +[float] +[id="{p}-dependencies-indirect"] +== Indirect dependencies + +[options="header"] +|=== +| Name | Version | Licence +{{ template "depRow" .Indirect }} +|=== +{{ end }} + +[float] +[id="{p}-dependencies-image"] +== Container image dependencies + +Dependencies included in the {n} container image. + +[options="header",format="csv"] +|=== +Name, Version, Licence, URL +include::container-image-dependencies.csv[] +|=== diff --git a/.github/workflows/generate-notice.yml b/.github/workflows/generate-notice.yml new file mode 100644 index 000000000..4763721a5 --- /dev/null +++ b/.github/workflows/generate-notice.yml @@ -0,0 +1,48 @@ +name: Generate NOTICE.MD + +on: + push: + workflow_dispatch: + +jobs: + generate-notice-file: + strategy: + matrix: + module: [ "quesma" ] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + cache-dependency-path: ${{ matrix.module }}/go.sum + go-version: '1.22' + + - name: Install go-licence-detector + working-directory: ${{ matrix.module }} + run: go get go.elastic.co/go-licence-detector && go install go.elastic.co/go-licence-detector + + - name: Generate NOTICE.MD + working-directory: ${{ matrix.module }} + run: | + go list -m -json all | go-licence-detector -includeIndirect -noticeTemplate=../.github/templates/NOTICE.txt.tmpl -noticeOut=../NOTICE.MD -depsTemplate=../.github/templates/dependencies.asciidoc.tmpl -depsOut=dependencies.asciidoc + rm dependencies.asciidoc + + - name: Print NOTICE.MD + run: cat NOTICE.MD + + - name: Issue a Pull Request + run: | + git checkout -b "notice/$(date +%Y%m%d%H%M%S)" + git config --local user.email "ai@quesma.com" + git config --local user.name "Quesma AI" + git add NOTICE.MD + git commit -m "Update NOTICE.MD" + git push origin HEAD + + gh pr create --title "Update NOTICE.MD" --body "This PR updates the NOTICE.MD file." --base main --head "notice/$(date +%Y%m%d%H%M%S)" + +