File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -242,14 +242,14 @@ jobs:
242242 run : |
243243 VERSION="${{ steps.process_release_version.outputs.version }}"
244244
245- # Check if comprehensive SBOM exists (generated during AMI build)
246245 if [ -f "nix-sbom.spdx.json" ]; then
247246 aws s3 cp nix-sbom.spdx.json \
248247 "s3://${{ secrets.SHARED_AWS_ARTIFACTS_BUCKET }}/sbom/${VERSION}/sbom.spdx.json" \
249248 --content-type "application/json"
250249 echo "::notice title=SBOM Uploaded::Comprehensive SBOM for ${VERSION} uploaded to shared artifacts"
251250 else
252- echo "::warning title=SBOM Missing::Comprehensive SBOM file not found, skipping upload"
251+ echo "::error title=SBOM Missing::SBOM file not found - build cannot proceed without SBOM"
252+ exit 1
253253 fi
254254
255255 - name : Create release
Original file line number Diff line number Diff line change 4343 fi
4444 done | sort -u | grep -v '^$'
4545 '' ;
46+
47+ # Combined wrapper that collects paths from profiles and generates SBOM
48+ sbom-from-profiles = pkgs . writeShellScriptBin "sbom-from-profiles" ''
49+ set -euo pipefail
50+ OUTPUT="'' ${1:-/tmp/nix-sbom.spdx.json}"
51+
52+ # Collect store paths from user profiles
53+ PATHS=$(${ collect-nix-paths } /bin/collect-nix-paths)
54+
55+ # Build --nix-target arguments
56+ ARGS=""
57+ while IFS= read -r path; do
58+ [ -n "$path" ] && ARGS="$ARGS --nix-target $path"
59+ done <<< "$PATHS"
60+
61+ # Generate combined SBOM
62+ ${ sbom-generator } /bin/sbom-generator $ARGS --output "$OUTPUT"
63+ '' ;
4664in
4765{
4866 inherit
4967 sbom
5068 sbom-ubuntu
5169 sbom-nix
5270 sbom-generator
71+ sbom-from-profiles
5372 collect-nix-paths
5473 sbomnix
5574 ;
Original file line number Diff line number Diff line change @@ -64,7 +64,22 @@ function cleanup_packages {
6464 sudo add-apt-repository --yes --remove ppa:ansible/ansible
6565}
6666
67+ function generate_sbom {
68+ echo " Generating combined SBOM from installed profiles..."
69+
70+ # Generate SBOM using the flake from GitHub at this exact commit
71+ nix run " github:supabase/postgres/${GIT_SHA} #sbom-from-profiles" -- /tmp/nix-sbom.spdx.json
72+
73+ echo " SBOM generated at /tmp/nix-sbom.spdx.json"
74+
75+ # Clean up SBOM tooling and old generations from nix store
76+ nix-collect-garbage -d
77+
78+ echo " Nix garbage collection complete"
79+ }
80+
6781install_packages
6882install_nix
6983execute_stage2_playbook
84+ generate_sbom
7085cleanup_packages
Original file line number Diff line number Diff line change @@ -128,4 +128,11 @@ build {
128128 script = " scripts/nix-provision.sh"
129129 }
130130
131+ # Download SBOM from AMI to runner
132+ provisioner "file" {
133+ source = " /tmp/nix-sbom.spdx.json"
134+ destination = " nix-sbom.spdx.json"
135+ direction = " download"
136+ }
137+
131138}
You can’t perform that action at this time.
0 commit comments