Skip to content

Commit bffdf05

Browse files
authored
Add SBOM generation and upload workflow for webui and cli packages (#1640)
Signed-off-by: Ioana Iliescu <ioana.iliescu@eclipse-foundation.org>
1 parent fabcda5 commit bffdf05

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Generate Yarn SBOM
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: "Release tag"
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: read
15+
16+
env:
17+
DT_PARENT_PROJECT_ID_CLI: "e4ead4c5-b141-4d4e-ab28-0d502b0be024"
18+
DT_PARENT_PROJECT_ID_WEBUI: "6db35d0e-dce5-4737-a4d1-4f4f2998edda"
19+
CYCLONEDX_YARN_PLUGIN_VERSION: "3.2.1"
20+
21+
jobs:
22+
generate-sbom:
23+
runs-on: ubuntu-latest
24+
if: >
25+
startsWith(github.event.release.tag_name || inputs.tag, 'cli-') ||
26+
startsWith(github.event.release.tag_name || inputs.tag, 'webui-')
27+
outputs:
28+
project-version: ${{ steps.metadata.outputs.PROJECT_VERSION }}
29+
product-name: ${{ steps.metadata.outputs.PRODUCT_NAME }}
30+
product-path: ${{ steps.metadata.outputs.PRODUCT_PATH }}
31+
parent-project-id: ${{ steps.metadata.outputs.PARENT_PROJECT_ID }}
32+
steps:
33+
- name: Resolve product metadata from tag
34+
id: metadata
35+
env:
36+
TAG: ${{ github.event.release.tag_name || inputs.tag }}
37+
run: |
38+
if [[ "$TAG" == cli-* ]]; then
39+
echo "PRODUCT_NAME=openvsx-cli" >> $GITHUB_OUTPUT
40+
echo "PRODUCT_PATH=cli" >> $GITHUB_OUTPUT
41+
echo "PARENT_PROJECT_ID=${{ env.DT_PARENT_PROJECT_ID_CLI }}" >> $GITHUB_OUTPUT
42+
echo "PROJECT_VERSION=${TAG#cli-}" >> $GITHUB_OUTPUT
43+
elif [[ "$TAG" == webui-* ]]; then
44+
echo "PRODUCT_NAME=openvsx-webui" >> $GITHUB_OUTPUT
45+
echo "PRODUCT_PATH=webui" >> $GITHUB_OUTPUT
46+
echo "PARENT_PROJECT_ID=${{ env.DT_PARENT_PROJECT_ID_WEBUI }}" >> $GITHUB_OUTPUT
47+
echo "PROJECT_VERSION=${TAG#webui-}" >> $GITHUB_OUTPUT
48+
fi
49+
50+
- name: Checkout repository at release tag
51+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
52+
with:
53+
ref: ${{ github.event.release.tag_name || inputs.tag }}
54+
persist-credentials: false
55+
56+
- name: Setup Node.js
57+
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
58+
with:
59+
node-version: '24.x'
60+
package-manager-cache: false
61+
registry-url: 'https://registry.npmjs.org'
62+
63+
- name: Enable Corepack (Yarn Berry)
64+
working-directory: ${{ steps.metadata.outputs.PRODUCT_PATH }}
65+
run: corepack enable
66+
67+
- name: Install dependencies
68+
working-directory: ${{ steps.metadata.outputs.PRODUCT_PATH }}
69+
run: yarn install --immutable
70+
71+
- name: Generate SBOM
72+
working-directory: ${{ steps.metadata.outputs.PRODUCT_PATH }}
73+
run: |
74+
yarn dlx -q @cyclonedx/yarn-plugin-cyclonedx@${{ env.CYCLONEDX_YARN_PLUGIN_VERSION }} \
75+
--output-format JSON \
76+
--output-file bom.json \
77+
--production
78+
79+
- name: Upload SBOM as artifact
80+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
81+
with:
82+
name: sbom
83+
path: ${{ steps.metadata.outputs.PRODUCT_PATH }}/bom.json
84+
85+
store-sbom-data:
86+
needs: ["generate-sbom"]
87+
uses: eclipse-csi/workflows/.github/workflows/store-sbom-data.yml@main
88+
with:
89+
projectName: ${{ needs.generate-sbom.outputs.product-name }}
90+
projectVersion: ${{ needs.generate-sbom.outputs.project-version }}
91+
bomArtifact: sbom
92+
bomFilename: bom.json
93+
parentProject: ${{ needs.generate-sbom.outputs.parent-project-id }}

0 commit comments

Comments
 (0)