|
| 1 | +name: SBOM |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: [published] |
| 5 | + |
| 6 | +permissions: read-all |
| 7 | + |
| 8 | +jobs: |
| 9 | + generate-sboms: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + env: |
| 12 | + NPM_CONFIG_UNSAFE_PERM: true |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - uses: actions/setup-node@v4 |
| 18 | + with: |
| 19 | + node-version: 20 |
| 20 | + |
| 21 | + - run: npm install -g npm@latest |
| 22 | + |
| 23 | + - name: Bootstrap |
| 24 | + run: npm ci |
| 25 | + |
| 26 | + - name: Generate SBOM for core packages |
| 27 | + if: ${{ ! startsWith(github.ref, 'refs/tags/experimental') && ! startsWith(github.ref, 'refs/tags/api') }} |
| 28 | + run: | |
| 29 | + for dir in $(find packages -mindepth 1 -maxdepth 1 -type d) |
| 30 | + do |
| 31 | + dir_name=$(basename "$dir") |
| 32 | + echo "Generating SBOM for $dir_name" |
| 33 | + npm sbom --sbom-format=spdx --legacy-peer-deps --workspace ${dir} > "opentelemetry-js_${dir_name}.spdx.json" |
| 34 | + done |
| 35 | + |
| 36 | + - name: Generate SBOM for the API package |
| 37 | + if: startsWith(github.ref, 'refs/tags/api/') |
| 38 | + run: | |
| 39 | + npm sbom --sbom-format=spdx --legacy-peer-deps --workspace api > opentelemetry-js_api.spdx.json |
| 40 | +
|
| 41 | + - name: Generate SBOMs for experimental packages |
| 42 | + if: startsWith(github.ref, 'refs/tags/experimental/') |
| 43 | + run: | |
| 44 | + for dir in $(find experimental/packages -mindepth 1 -maxdepth 1 -type d) |
| 45 | + do |
| 46 | + dir_name=$(basename "$dir") |
| 47 | + echo "Generating SBOM for $dir_name" |
| 48 | + npm sbom --sbom-format=spdx --legacy-peer-deps --workspace ${dir} > "opentelemetry-js_${dir_name}.spdx.json" |
| 49 | + done |
| 50 | +
|
| 51 | + - name: Zip all SBOM files |
| 52 | + run: | |
| 53 | + zip sbom.zip *.spdx.json |
| 54 | +
|
| 55 | + - name: Upload artifact |
| 56 | + uses: actions/upload-artifact@v4 |
| 57 | + with: |
| 58 | + name: SBOM.zip |
| 59 | + path: ./sbom.zip |
| 60 | + |
| 61 | + add-release-artifact: |
| 62 | + needs: generate-sboms |
| 63 | + runs-on: ubuntu-latest |
| 64 | + permissions: |
| 65 | + contents: write |
| 66 | + steps: |
| 67 | + - name: Download artifact from generate-sboms |
| 68 | + uses: actions/download-artifact@v4 |
| 69 | + with: |
| 70 | + name: SBOM.zip |
| 71 | + - name: Upload release asset |
| 72 | + uses: actions/upload-release-asset@v1 |
| 73 | + env: |
| 74 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + with: |
| 76 | + upload_url: ${{ github.event.release.upload_url }} |
| 77 | + asset_path: ./sbom.zip |
| 78 | + asset_name: SBOM.zip |
| 79 | + asset_content_type: application/zip |
0 commit comments