Skip to content

Commit 0970eee

Browse files
committed
[gha] Automate Windows/macOS SBOM request
1 parent 0884df6 commit 0970eee

1 file changed

Lines changed: 122 additions & 0 deletions

File tree

‎.github/workflows/sbom-request.yml‎

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: SBOM and secscan
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
email:
7+
description: 'Canonical email address to receive SBOM completion notifications'
8+
required: true
9+
tag:
10+
description: 'Release tag to scan (e.g. v1.16.3 or v1.17.0-rc1).'
11+
required: true
12+
release:
13+
description: 'Release cycle (e.g. 25.04).'
14+
required: true
15+
16+
permissions: {}
17+
18+
jobs:
19+
snap:
20+
if: ${{ github.repository == 'canonical/multipass' }}
21+
22+
# Requires a runner with Canonical VPN access via a private endpoint.
23+
runs-on: [self-hosted-linux-amd64-noble-small]
24+
25+
steps:
26+
- uses: actions/checkout@v6
27+
with:
28+
persist-credentials: false
29+
sparse-checkout: .github/.sbomber-manifest-snap.yaml
30+
31+
- name: Render manifest
32+
run: |
33+
sed "s/__EMAIL__/${{ inputs.email }}/g" "$GITHUB_WORKSPACE/.github/.sbomber-manifest-snap.yaml" > "$RUNNER_TEMP/sbomber-manifest.yaml"
34+
cat "$RUNNER_TEMP/sbomber-manifest.yaml"
35+
36+
- name: sbomber (snap)
37+
uses: canonical/sbomber/.github/actions/run@cf7a76e810497ec932e8285b2c9d6b373d225e79 # main
38+
with:
39+
manifest: '${{ runner.temp }}/sbomber-manifest.yaml'
40+
artifact-name: secscan-report-upload-snap
41+
sbomber-ref: cf7a76e810497ec932e8285b2c9d6b373d225e79 # should match the ref in 'uses' above
42+
43+
installers:
44+
if: ${{ github.repository == 'canonical/multipass' }}
45+
46+
runs-on: [self-hosted-linux-amd64-noble-small]
47+
48+
steps:
49+
- uses: actions/checkout@v6
50+
with:
51+
persist-credentials: false
52+
sparse-checkout: tools/ssdlc/request-installer-sboms.py
53+
54+
- name: Download release installers
55+
id: release
56+
# Download the .pkg and .msi assets from the given release tag.
57+
run: |
58+
TAG="${{ inputs.tag }}"
59+
VERSION="${TAG#v}"
60+
VERSION="${VERSION%%-rc*}"
61+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
62+
63+
mkdir -p "$RUNNER_TEMP/installers"
64+
gh release download "$TAG" \
65+
--repo "${{ github.repository }}" \
66+
--pattern "*.pkg" \
67+
--pattern "*.msi" \
68+
--dir "$RUNNER_TEMP/installers"
69+
ls -lh "$RUNNER_TEMP/installers"
70+
env:
71+
GH_TOKEN: ${{ github.token }}
72+
73+
- name: Install Python dependencies
74+
uses: BSFishy/pip-action@v1
75+
with:
76+
requirements: tools/ssdlc/requirements.txt
77+
78+
- name: Request installer SBOMs
79+
id: installer-sboms
80+
# sbomber does not support macOS/Windows installers. Use the SBOM REST API directly
81+
# via request-installer-sboms.py. secscan is also skipped.
82+
run: |
83+
REPORTS_DIR="$RUNNER_TEMP/sboms-installers"
84+
PIDS=()
85+
86+
for f in "$RUNNER_TEMP/installers"/*.pkg "$RUNNER_TEMP/installers"/*.msi; do
87+
[ -f "$f" ] || continue
88+
case "$f" in
89+
*.pkg)
90+
ARCH="amd64"
91+
;;
92+
*.msi)
93+
# Default arch to amd64
94+
[[ "$f" == *win64* ]] && ARCH="amd64" || ARCH="amd64"
95+
;;
96+
esac
97+
98+
tools/ssdlc/request_sboms.py \
99+
--email "${{ inputs.email }}" \
100+
--version "${{ steps.release.outputs.version }}" \
101+
--output-dir "$REPORTS_DIR" \
102+
--arch "$ARCH" \
103+
--release "${{ inputs.release }}" \
104+
"$f" &
105+
PIDS+=($!)
106+
done
107+
108+
if [ ${#PIDS[@]} -eq 0 ]; then
109+
echo "::warning::No .pkg or .msi installers found; skipping installer SBOMs"
110+
else
111+
for pid in "${PIDS[@]}"; do wait "$pid"; done
112+
echo "reports_dir=$REPORTS_DIR" >> "$GITHUB_OUTPUT"
113+
fi
114+
115+
- name: Upload installer SBOMs
116+
if: always()
117+
uses: actions/upload-artifact@v7
118+
with:
119+
name: sboms-installers-${{ inputs.tag }}
120+
path: ${{ steps.installer-sboms.outputs.reports_dir }}
121+
if-no-files-found: warn
122+
retention-days: 90

0 commit comments

Comments
 (0)