-
-
Notifications
You must be signed in to change notification settings - Fork 7
108 lines (90 loc) · 3.17 KB
/
Copy pathsbom.yml
File metadata and controls
108 lines (90 loc) · 3.17 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
name: Generate SBOM
on:
# Allow being called from other workflows (e.g., publish workflow)
workflow_call:
outputs:
sbom-json-path:
description: 'Path to the generated SBOM JSON file'
value: ${{ jobs.generate-sbom.outputs.sbom-json-path }}
# Optional manual trigger for release artifact generation/debugging.
workflow_dispatch:
permissions:
contents: read
defaults:
run:
working-directory: pywry
jobs:
generate-sbom:
name: Generate merged CycloneDX SBOM (JSON)
runs-on: ubuntu-latest
outputs:
sbom-json-path: ${{ steps.paths.outputs.sbom-json-path }}
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version: '22'
- name: Install project dependencies
run: pip install ".[all,dev,freeze]"
- name: Install CycloneDX tools
run: |
pip install cyclonedx-bom
npm ci --ignore-scripts
- name: Generate Python dependency SBOM
run: |
cyclonedx-py environment --pyproject pyproject.toml --output-format JSON --output-file sbom-python.cdx.json
- name: Generate npm dependency SBOM
run: |
npx @cyclonedx/cyclonedx-npm --package-lock-only --output-format JSON --output-file sbom-node.cdx.json
- name: Merge Python + npm SBOMs
run: |
docker run --rm \
-v "$PWD:/work" \
-w /work \
cyclonedx/cyclonedx-cli:latest \
merge \
--input-files sbom-python.cdx.json sbom-node.cdx.json \
--output-format json \
--output-file sbom.cdx.json
- name: Validate merged SBOM
run: |
docker run --rm \
-v "$PWD:/work" \
-w /work \
cyclonedx/cyclonedx-cli:latest \
validate \
--input-file sbom.cdx.json \
--input-format json \
--fail-on-errors
- name: Record SBOM output paths
id: paths
run: |
echo "sbom-json-path=sbom.cdx.json" >> $GITHUB_OUTPUT
- name: Display SBOM summary
run: |
echo "## SBOM Generated Successfully" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Format:** CycloneDX JSON" >> $GITHUB_STEP_SUMMARY
echo "**Scope:** Python + npm dependency chains" >> $GITHUB_STEP_SUMMARY
echo "**Generated:** $(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
COMPONENT_COUNT=$(python - <<'PY'
import json
from pathlib import Path
data = json.loads(Path('sbom.cdx.json').read_text())
print(len(data.get('components', [])))
PY
)
echo "**Components:** $COMPONENT_COUNT" >> $GITHUB_STEP_SUMMARY
- name: Upload SBOM as artifact
uses: actions/upload-artifact@v7
with:
name: sbom
path: sbom.cdx.json
retention-days: 90