Skip to content

Commit add407c

Browse files
committed
add dependency licenses to release artifacts
1 parent e7a46dd commit add407c

File tree

6 files changed

+44
-2
lines changed

6 files changed

+44
-2
lines changed

.github/workflows/container-image.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ jobs:
1111
runs-on: "ubuntu-latest"
1212
steps:
1313
- uses: actions/checkout@v3
14+
15+
- name: Install Go
16+
uses: actions/setup-go@v3
17+
with:
18+
go-version: '^1.18'
19+
20+
- name: Create Licenses Report
21+
run: |
22+
make licenses-report
1423
1524
- name: Login to GitHub Container Registry
1625
uses: docker/[email protected]

.github/workflows/draft_release.yaml

+10-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
uses: softprops/action-gh-release@v1
3131
with:
3232
draft: true
33-
files: out/*
33+
files: out/*.*
3434
# body_path: _releasenotes/${{ env.RELEASE_TAG }}.md
3535

3636
release_image:
@@ -39,6 +39,15 @@ jobs:
3939
steps:
4040
- name: Check out the repo
4141
uses: actions/checkout@v3
42+
43+
- name: Install Go
44+
uses: actions/setup-go@v3
45+
with:
46+
go-version: '^1.18'
47+
48+
- name: Create Licenses Report
49+
run: |
50+
make licenses-report
4251
4352
- name: Login to GitHub Container Registry
4453
uses: docker/[email protected]

Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ WORKDIR /
2828
COPY --from=builder /workspace/manager .
2929
USER 65532
3030

31+
# Add directory containing the licenses of all dependencies
32+
COPY out/licenses /licenses
33+
3134
ENTRYPOINT ["/manager"]

Makefile

+13-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
7272
go run ./main.go
7373

7474
.PHONY: docker-build
75-
docker-build: test ## Build docker image with the manager.
75+
docker-build: test licenses-report ## Build docker image with the manager.
7676
docker build -t ${IMG} .
7777

7878
.PHONY: docker-push
@@ -97,6 +97,7 @@ release: clean-release
9797
$(MAKE) set-manifest-pull-policy PULL_POLICY=IfNotPresent
9898
$(MAKE) release-manifests
9999
$(MAKE) release-metadata
100+
$(MAKE) licenses-report
100101
$(MAKE) clean-release-git
101102

102103
.PHONY: clean-release
@@ -115,6 +116,12 @@ release-manifests: kustomize $(RELEASE_DIR)
115116
release-metadata:
116117
cp metadata.yaml $(RELEASE_DIR)/metadata.yaml
117118

119+
licenses-report: go-licenses
120+
rm -rf $(RELEASE_DIR)/licenses
121+
$(GO_LICENSES) save --save_path $(RELEASE_DIR)/licenses ./...
122+
$(GO_LICENSES) report --template hack/licenses.md.tpl ./... > $(RELEASE_DIR)/licenses/licenses.md
123+
(cd out/licenses && tar -czf ../licenses.tar.gz *)
124+
118125
##@ Release Utils
119126

120127
.PHONY: set-manifest-pull-policy
@@ -164,3 +171,8 @@ ENVTEST = $(HACK_BIN)/setup-envtest
164171
.PHONY: envtest
165172
envtest: ## Download envtest-setup locally if necessary.
166173
env GOBIN=$(HACK_BIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
174+
175+
GO_LICENSES = $(HACK_BIN)/go-licenses
176+
.PHONY: go-licenses
177+
go-licenses:
178+
env GOBIN=$(HACK_BIN) go install github.com/google/go-licenses@latest

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ Licensed under the **Apache License, Version 2.0** (the "License"); you may not
3737
You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0.
3838
3939
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the [LICENSE](./LICENSE) for the specific language governing permissions and limitations under the License.
40+
41+
### Dependency Licenses
42+
43+
You can find the licenses of used Go dependencies as a `licenses.tar.gz` archive as part of our [releases](https://github.com/telekom/cluster-api-ipam-provider-in-cluster/releases) and in the `/license` directory contained in our container images available at [ghcr.io/telekom/cluster-api-ipam-provider-in-cluster](https://ghcr.io/telekom/cluster-api-ipam-provider-in-cluster).

hack/licenses.md.tpl

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Dependency Licenses
2+
3+
{{ range . }}
4+
- {{.Name}}@{{.Version}} ([{{.LicenseName}}]({{.LicenseURL}}))
5+
{{- end }}

0 commit comments

Comments
 (0)