Skip to content

Commit 148ecc2

Browse files
committed
generate sbom as part of release build and upload it to maven central
Signed-off-by: studix <[email protected]>
1 parent 3e6e7e7 commit 148ecc2

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

.github/workflows/release.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
- name: Build
3838
run: ./gradlew build reckonTagPush -Preckon.stage=final -Preckon.scope=${{ github.event.inputs.releaseType }} --stacktrace
3939

40+
- name: Generate SBOM
41+
run: ./gradlew --init-script init.gradle cyclonedxBom
42+
4043
- name: Release
4144
run: ./gradlew publish --no-configuration-cache
4245
env:

datalift-commandline/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ mavenPublishing {
4848
classifier = "bin"
4949
extension = "tar.gz"
5050
}
51+
artifact(file("$buildDir/reports/bom.json")) {
52+
classifier = "sbom"
53+
extension = "json"
54+
}
5155
}
5256
}
5357
}

datalift-core/build.gradle

+13
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ mavenPublishing {
5454
developerConnection = "scm:git:ssh://[email protected]/BisonSchweizAG/commercetools-datalift.git"
5555
}
5656
}
57+
58+
afterEvaluate {
59+
publishing {
60+
publications {
61+
maven(MavenPublication) {
62+
artifact(file("$buildDir/reports/bom.json")) {
63+
classifier = "sbom"
64+
extension = "json"
65+
}
66+
}
67+
}
68+
}
69+
}
5770
}
5871

5972
test {

init.gradle

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import org.cyclonedx.model.*;
2+
3+
initscript {
4+
repositories {
5+
maven {
6+
url "https://plugins.gradle.org/m2/"
7+
}
8+
}
9+
dependencies {
10+
classpath "org.cyclonedx:cyclonedx-gradle-plugin:2.2.0"
11+
}
12+
}
13+
14+
allprojects {
15+
apply plugin: org.cyclonedx.gradle.CycloneDxPlugin
16+
cyclonedxBom {
17+
includeConfigs = ["runtimeClasspath"]
18+
// declaration of the Object from OrganizationalContact
19+
OrganizationalContact organizationalContact = new OrganizationalContact()
20+
21+
// passing Data to the plugin
22+
organizationalEntity { oe ->
23+
oe.name = 'Bison Schweiz AG'
24+
oe.url = ['www.bison-group.com']
25+
oe.addContact(organizationalContact)
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)