Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: generate sboms for provided packeges in a release #247

Merged
merged 9 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Install syft for sbom generation
uses: anchore/sbom-action/[email protected]

- name: Build snapshot artifacts
uses: goreleaser/goreleaser-action@v6
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/e2e_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ jobs:
"network_plugin": "kathara/katharanp_vde"
}' > ~/.config/kathara.conf

- name: Install syft for sbom generation
uses: anchore/sbom-action/[email protected]

- name: Build binary for e2e
uses: goreleaser/goreleaser-action@v6
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
registry: mtr.devops.telekom.de
username: ${{ secrets.MTR_USERNAME }}
password: ${{ secrets.MTR_PASSWORD }}

- name: Install syft for sbom generation
uses: anchore/sbom-action/[email protected]

- name: Build, push & release
uses: goreleaser/goreleaser-action@v6
Expand Down
3 changes: 3 additions & 0 deletions .goreleaser-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: 2
project_name: sparrow
snapshot:
name_template: "commit-{{ .ShortCommit }}"
Expand Down Expand Up @@ -25,3 +26,5 @@ dockers:
- --label=org.opencontainers.image.created={{ .Timestamp }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses="Apache 2.0"
sboms:
- artifacts: archive
6 changes: 6 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: 2
project_name: sparrow
builds:
- env: [CGO_ENABLED=0]
Expand Down Expand Up @@ -39,3 +40,8 @@ nfpms:
- deb
- rpm
- apk
sboms:
- id: archive
artifacts: archive
- id: source
artifacts: source
23 changes: 23 additions & 0 deletions scripts/sbom/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generate SBOM with Syft

This doc can be used to generate a SBOM manually with [Syft](https://github.com/anchore/syft).

## Usage

Install the Syft binary.

Use the following command to generate a simple SBOM file form the repository:

```shell
syft .
```

Alternative output variants can be found [here](https://github.com/anchore/syft/wiki/Output-Formats).

Use the following command to generate a SBOM markdown file using the `example.sbom.tmpl` goTemplate template file:

```shell
SYFT_GOLANG_SEARCH_REMOTE_LICENSES=true syft ghcr.io/telekom/sparrow:v0.5.0 -o template -t scripts/sbom/example.sbom.tmpl
```

Setting the env variable `SYFT_GOLANG_SEARCH_REMOTE_LICENSES=true` will ensure to lookup licenses remotely. In this example the sparrow image in version `v0.5.0` is scanned.
5 changes: 5 additions & 0 deletions scripts/sbom/example.sbom.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| Package | Type | Version | Licenses |
| ------- | ---- | ------- | -------- |
{{- range .artifacts}}
| {{.name}} | {{.type}} | {{.version}} | {{range $index, $licence := .licenses}}{{- if $index}}, {{end}}{{$licence.value}}{{end}} |
{{- end}}
Loading