-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (138 loc) · 5.75 KB
/
Copy pathbuild-sboms.yml
File metadata and controls
156 lines (138 loc) · 5.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Build & Sign SBOMs
# Push a plain version tag (e.g. "4.2.3") to trigger a build. The tag itself
# is the OOD version to build — there's no separate input to keep in sync.
on:
push:
tags:
- "*.*.*"
env:
# Pins the syft version used by every job. Bump when a new syft release
# is worth picking up — see https://github.com/anchore/syft/releases
SYFT_VERSION: v1.48.0
jobs:
build:
name: ${{ matrix.distro }} / ${{ matrix.arch }}
runs-on: ${{ matrix.runner }}
permissions:
contents: read
id-token: write # required for cosign keyless (Fulcio) signing
strategy:
fail-fast: false
matrix:
distro: [amzn2023, el8, el9, el10, noble, resolute, bookworm, trixie]
arch: [x86_64, aarch64]
include:
- arch: x86_64
runner: ubuntu-24.04
- arch: aarch64
runner: ubuntu-24.04-arm
# ppc64le is intentionally not covered here — no GitHub-hosted
# runner exists for it. See issue #1 for the self-hosted /
# IBM-managed-runner path being explored separately.
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Derive OOD version from tag
id: version
run: |
VERSION="${GITHUB_REF_NAME}"
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Tag '$VERSION' isn't a plain semver OOD version (e.g. 4.2.3) — refusing to build."
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "major_minor=${VERSION%.*}" >> "$GITHUB_OUTPUT"
- name: Install syft
run: ./scripts/install-syft.sh
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Build & scan ${{ matrix.distro }}/${{ matrix.arch }}
env:
ARCH: ${{ matrix.arch }}
USE_COSIGN: "1"
COSIGN_MODE: keyless
run: ./scripts/scan-all.sh "${{ steps.version.outputs.version }}" "${{ matrix.distro }}"
- name: Upload SBOM artifact
uses: actions/upload-artifact@v4
with:
name: sbom-${{ matrix.distro }}-${{ matrix.arch }}
path: ${{ steps.version.outputs.major_minor }}/**/*
if-no-files-found: error
retention-days: 7
publish:
name: Open PR with generated SBOMs
needs: build
# Run with whatever succeeded, even if some distro/arch legs failed --
# OSC's staging repo doesn't always have every arch built for every
# distro at the same time (amzn2023/el10 lag on aarch64 as of 4.2.4).
# Only skip if the whole run was cancelled outright.
if: ${{ !cancelled() }}
runs-on: ubuntu-24.04
permissions:
contents: write
pull-requests: write
id-token: write # required for cosign keyless signing of checksums.txt
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Derive OOD version from tag
id: version
run: |
VERSION="${GITHUB_REF_NAME}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "major_minor=${VERSION%.*}" >> "$GITHUB_OUTPUT"
- name: Download all SBOM artifacts
uses: actions/download-artifact@v4
with:
pattern: sbom-*
path: _artifacts
merge-multiple: true
# If every leg failed there's nothing to publish -- fail here
# rather than continue on to an empty/no-op PR.
if-no-artifact-found: error
- name: Merge into the repo tree
run: |
# upload-artifact strips everything before the first wildcard in
# the upload path (4.2/**/* -> artifacts rooted at <distro>/<arch>/),
# so the major.minor prefix has to be put back here.
MM="${{ steps.version.outputs.major_minor }}"
mkdir -p "$MM"
cp -a _artifacts/. "$MM/"
rm -rf _artifacts
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Rebuild & sign checksums.txt
env:
USE_COSIGN: "1"
COSIGN_MODE: keyless
run: ./scripts/build-checksums.sh "${{ steps.version.outputs.major_minor }}"
- name: Open PR
uses: peter-evans/create-pull-request@v6
with:
# Required: this workflow is only ever triggered by a tag push,
# which leaves the checkout in a detached-HEAD state (same as
# `release` events). Without an explicit base, the action can't
# figure out what branch to open the PR against.
base: main
commit-message: "sboms: add ${{ steps.version.outputs.version }} (x86_64 + aarch64, all distros)"
branch: "sbom/${{ steps.version.outputs.version }}"
title: "SBOMs for OOD ${{ steps.version.outputs.version }}"
body: |
Auto-generated by the `Build & Sign SBOMs` workflow for tag
`${{ steps.version.outputs.version }}`.
Covers `x86_64` and `aarch64` for every distro that had a
successful build in this run. If a distro/arch combo you'd
expect isn't here, check this run's job list for a red leg —
OSC's staging repo doesn't always have every arch built for
every distro at the same time (see #1 / the aarch64-lag issue
for known gaps). Re-tag once the missing build lands upstream
to backfill it.
`checksums.txt` and each individual SBOM are signed keylessly
via cosign/Fulcio — verify with:
```
cosign verify-blob --certificate <file>.pem --signature <file>.sig \
--certificate-identity-regexp '.*' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
<file>
```
add-paths: "${{ steps.version.outputs.major_minor }}/**"