Skip to content

Commit ff01bdd

Browse files
committed
[gha] Automate Windows/macOS SBOM request
1 parent b391587 commit ff01bdd

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

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

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ on:
66
email:
77
description: 'Canonical email address to receive SBOM completion notifications'
88
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
915

1016
permissions: {}
1117

@@ -33,3 +39,84 @@ jobs:
3339
manifest: '${{ runner.temp }}/sbomber-manifest.yaml'
3440
artifact-name: secscan-report-upload-snap
3541
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)