Skip to content

Commit

Permalink
Generate NOTICE.MD workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit committed Jul 5, 2024
1 parent 6b710a2 commit d100690
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/templates/NOTICE.txt.tmpl
Original file line number Diff line number Diff line change
@@ -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 }}
51 changes: 51 additions & 0 deletions .github/templates/dependencies.asciidoc.tmpl
Original file line number Diff line number Diff line change
@@ -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[]
|===
50 changes: 50 additions & 0 deletions .github/workflows/generate-notice.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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 "[email protected]"
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)"
env:
GH_TOKEN: ${{ github.token }}


0 comments on commit d100690

Please sign in to comment.