Skip to content

Commit 4cb2657

Browse files
authored
Add SBOM generation script and update release docs (#7441)
Add tools/generate-sbom.sh to automate SBOM generation for releases, replacing the manual steps in RELEASE.md. The script covers all container images (cortex, query-tee, test-exporter, thanosconvert) and packages the output into dist/sbom.tar.gz. Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com>
1 parent 53f7ae7 commit 4cb2657

2 files changed

Lines changed: 43 additions & 7 deletions

File tree

RELEASE.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,11 @@ To publish a stable release:
133133

134134
### <a name="sing-and-sbom"></a>Sign the release artifacts and generate SBOM
135135
1. Make sure you have the release branch checked out, and you don't have any local modifications
136-
1. Create and `cd` to an empty directory not within the project directory
137-
1. Run `mkdir sbom`
138-
1. Generate SBOMs using https://github.com/kubernetes-sigs/bom
139-
1. `bom generate -o sbom/go-mod.spdx -n https://github.com/cortexproject/cortex -d <cortex repo>`
140-
1. `bom generate -o sbom/cortex-container-image.spdx -n https://github.com/cortexproject/cortex -i quay.io/cortexproject/cortex:<release tag>`
141-
1. `bom generate -o sbom/query-tee-container-image.spdx -n https://github.com/cortexproject/cortex -i quay.io/cortexproject/query-tee:<release tag>`
142-
1. `tar -zcvf sbom.tar.gz sbom`
136+
1. Generate SBOMs using the provided script (requires https://github.com/kubernetes-sigs/bom):
137+
```bash
138+
./tools/generate-sbom.sh /path/to/cortex
139+
```
140+
This generates SBOMs for the Go modules and all container images (cortex, query-tee, test-exporter, thanosconvert) and packages them into `dist/sbom.tar.gz`.
143141
1. Download the artifacts attached to the published release
144142
```bash
145143
curl -H "Authorization: Bearer <your GitHub API token>" -s https://api.github.com/repos/cortexproject/cortex/releases/tags/<release tag> \

tools/generate-sbom.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
5+
RELEASE_TAG="v$(cat "${REPO_ROOT}/VERSION" | tr -d '[:space:]')"
6+
CORTEX_REPO="${1:-$REPO_ROOT}"
7+
8+
mkdir -p sbom
9+
10+
echo "Generating go-mod SBOM..."
11+
bom generate -o sbom/go-mod.spdx \
12+
-n https://github.com/cortexproject/cortex \
13+
-d "$CORTEX_REPO"
14+
15+
echo "Generating cortex container image SBOM..."
16+
bom generate -o sbom/cortex-container-image.spdx \
17+
-n https://github.com/cortexproject/cortex \
18+
-i "quay.io/cortexproject/cortex:${RELEASE_TAG}"
19+
20+
echo "Generating query-tee container image SBOM..."
21+
bom generate -o sbom/query-tee-container-image.spdx \
22+
-n https://github.com/cortexproject/cortex \
23+
-i "quay.io/cortexproject/query-tee:${RELEASE_TAG}"
24+
25+
echo "Generating test-exporter container image SBOM..."
26+
bom generate -o sbom/test-exporter-container-image.spdx \
27+
-n https://github.com/cortexproject/cortex \
28+
-i "quay.io/cortexproject/test-exporter:${RELEASE_TAG}"
29+
30+
echo "Generating thanosconvert container image SBOM..."
31+
bom generate -o sbom/thanosconvert-container-image.spdx \
32+
-n https://github.com/cortexproject/cortex \
33+
-i "quay.io/cortexproject/thanosconvert:${RELEASE_TAG}"
34+
35+
echo "Creating sbom.tar.gz..."
36+
tar -zcvf "${REPO_ROOT}/dist/sbom.tar.gz" sbom
37+
38+
echo "Done. sbom.tar.gz is at ${REPO_ROOT}/dist/sbom.tar.gz"

0 commit comments

Comments
 (0)