|
| 1 | +name: Generate Maven SBOM |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v**" # Triggers when someone pushes a tag that starts with 'v' |
| 7 | + |
| 8 | + workflow_dispatch: |
| 9 | + # The custom 'Version' input field allows running the workflow for older git |
| 10 | + # refs, where this workflow file did not exist yet. This would not be |
| 11 | + # possible with the builtin "Use workflow from" input field. |
| 12 | + inputs: |
| 13 | + version: |
| 14 | + description: "Version" |
| 15 | + default: "master" |
| 16 | + required: true |
| 17 | + |
| 18 | +env: |
| 19 | + JAVA_VERSION: '17' |
| 20 | + JAVA_DISTRO: 'temurin' |
| 21 | + PLUGIN_VERSION: '2.9.1' |
| 22 | + SBOM_TYPE: 'makeAggregateBom' |
| 23 | + PROJECT_VERSION: "${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.version }}" |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: read |
| 27 | + |
| 28 | +jobs: |
| 29 | + generate-sbom: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + outputs: |
| 32 | + # Make env var available in re-usuable workflow (see actions/runner#2372) |
| 33 | + project-version: ${{ env.PROJECT_VERSION }} |
| 34 | + steps: |
| 35 | + - name: Checkout repository at '${{ env.PROJECT_VERSION }}' |
| 36 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 37 | + with: |
| 38 | + fetch-depth: 0 |
| 39 | + ref: ${{ env.PROJECT_VERSION }} |
| 40 | + persist-credentials: false |
| 41 | + |
| 42 | + - name: Setup Java SDK |
| 43 | + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 |
| 44 | + with: |
| 45 | + java-version: ${{ env.JAVA_VERSION }} |
| 46 | + distribution: ${{ env.JAVA_DISTRO }} |
| 47 | + |
| 48 | + - name: Generate |
| 49 | + run: | |
| 50 | + mvn org.cyclonedx:cyclonedx-maven-plugin:${PLUGIN_VERSION}:${SBOM_TYPE} \ |
| 51 | + -DoutputFormat=json \ |
| 52 | + -DoutputDirectory=target \ |
| 53 | + -DoutputName=cyclonedx |
| 54 | +
|
| 55 | +
|
| 56 | + - name: Upload |
| 57 | + uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 |
| 58 | + with: |
| 59 | + name: sbom |
| 60 | + path: target/cyclonedx.json |
| 61 | + |
| 62 | + # Store SBOM and metadata in a predefined format for otterdog to pick up |
| 63 | + store-sbom-data: |
| 64 | + needs: ['generate-sbom'] |
| 65 | + uses: eclipse-csi/workflows/.github/workflows/store-sbom-data.yml@main |
| 66 | + with: |
| 67 | + projectName: 'JGit' |
| 68 | + projectVersion: ${{ needs.generate-sbom.outputs.project-version }} |
| 69 | + bomArtifact: 'sbom' |
| 70 | + bomFilename: 'cyclonedx.json' |
| 71 | + parentProject: '6638fa7e-8518-4528-9419-e24f629b7e9f' |
| 72 | + |
0 commit comments