Skip to content

Commit d7896ec

Browse files
authored
Upload a haskell SBOM to GH (#1206)
* Upload a haskell SBOM to GH * pin index-state and fix CI
1 parent 971f08b commit d7896ec

2 files changed

Lines changed: 102 additions & 0 deletions

File tree

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Dependency submission
2+
3+
on:
4+
push:
5+
branches: [development, main]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: dependency-submission-${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
submit-dependencies:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout target project
22+
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
23+
with:
24+
path: project
25+
26+
- name: Checkout cabal-plan-submit
27+
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0'
28+
with:
29+
repository: dancewithheart/cabal-plan-submit
30+
path: cabal-plan-submit
31+
32+
- name: Setup Haskell
33+
uses: haskell-actions/setup@cd0d9bdd65b20557f41bea4dbe43d0b5fbbfe553 # v2.11.0'
34+
with:
35+
ghc-version: "9.10.3"
36+
cabal-version: "3.16.1.0"
37+
38+
- name: Cache Cabal store
39+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0'
40+
with:
41+
path: |
42+
~/.cabal/store
43+
~/.cabal/packages
44+
cabal-plan-submit/dist-newstyle
45+
project/dist-newstyle
46+
key: ${{ runner.os }}-ghc-9.10.3-${{ hashFiles('project/**/*.cabal', 'project/cabal.project*', 'cabal-plan-submit/**/*.cabal', 'cabal-plan-submit/cabal.project*') }}
47+
restore-keys: |
48+
${{ runner.os }}-ghc-9.10.3-
49+
50+
- name: Configure environment
51+
working-directory: project
52+
run: |
53+
./.github/workflows/setup.sh
54+
cabal update
55+
56+
- name: Build target project
57+
working-directory: project
58+
run: cabal build all --dry-run
59+
60+
- name: Build cabal-plan-submit
61+
working-directory: cabal-plan-submit
62+
run: cabal build exe:cabal-plan-submit
63+
64+
- name: Render and validate dependency snapshot
65+
working-directory: project
66+
env:
67+
SHA: ${{ github.sha }}
68+
REF: ${{ github.ref }}
69+
run: |
70+
BIN="$(cd ../cabal-plan-submit && cabal list-bin exe:cabal-plan-submit | tail -n 1)"
71+
"$BIN" render-snapshot dist-newstyle/cache/plan.json "$SHA" "$REF" > ../snapshot.json
72+
"$BIN" validate-snapshot ../snapshot.json
73+
74+
- name: Submit dependency snapshot
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
REPO: ${{ github.repository }}
78+
run: |
79+
owner="${REPO%/*}"
80+
repo="${REPO#*/}"
81+
82+
response="$(
83+
curl \
84+
--fail-with-body \
85+
-X POST \
86+
-H "Accept: application/vnd.github+json" \
87+
-H "Authorization: Bearer $GITHUB_TOKEN" \
88+
-H "X-GitHub-Api-Version: 2022-11-28" \
89+
"https://api.github.com/repos/$owner/$repo/dependency-graph/snapshots" \
90+
--data-binary @snapshot.json
91+
)"
92+
93+
echo "$response" | jq .
94+
95+
snapshot_id="$(echo "$response" | jq -r '.id')"
96+
snapshot_url="https://api.github.com/repos/$owner/$repo/dependency-graph/snapshots/$snapshot_id"
97+
98+
echo "Snapshot API URL: $snapshot_url"
99+
echo "Snapshot result: $(echo "$response" | jq -r '.result')"
100+
echo "Snapshot message: $(echo "$response" | jq -r '.message')"

cabal.project

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,5 @@ source-repository-package
103103
arbiter-servant
104104
arbiter-servant-ui
105105
arbiter-test-common
106+
107+
index-state: 2026-07-30T07:30:12Z

0 commit comments

Comments
 (0)