Skip to content

Commit b873690

Browse files
committed
first attempt at CI with gradle
1 parent 2a5dc3e commit b873690

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
with:
2020
java-version: '8'
2121
distribution: 'temurin'
22-
cache: maven
22+
cache: gradle
2323
server-id: ossrh
2424
server-username: MAVEN_USERNAME
2525
server-password: MAVEN_PASSWORD
26-
- name: Build with Maven
27-
run: ./mvnw -B package deploy -Djavacan.compile-script="$PWD/ci/compile-native.sh" -Pall-architectures,android
26+
- name: Build
27+
run: ./gradlew publish
2828
env:
2929
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
3030
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}

conventions/src/main/kotlin/tel.schich.javacan.convention.native.gradle.kts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.gradle.configurationcache.extensions.capitalized
2+
import tel.schich.dockcross.execute.DockerRunner
23
import tel.schich.dockcross.execute.NonContainerRunner
34
import tel.schich.dockcross.tasks.DockcrossRunTask
45

@@ -7,6 +8,8 @@ plugins {
78
id("tel.schich.dockcross")
89
}
910

11+
val ci = System.getenv("CI") != null
12+
1013
val archDetectConfiguration by configurations.registering {
1114
isCanBeConsumed = true
1215
}
@@ -98,6 +101,10 @@ fun DockcrossRunTask.baseConfigure(linkMode: NativeLinkMode, outputTo: Directory
98101
listOf("cmake", relativePathToProject, projectVersionOption, releaseOption, linkStaticallyOption),
99102
listOf("make", "-j${project.gradle.startParameter.maxWorkerCount}"),
100103
)
104+
105+
if (ci) {
106+
runner(DockerRunner())
107+
}
101108
}
102109

103110
fun Jar.baseConfigure(compileTask: TaskProvider<DockcrossRunTask>, buildOutputDir: Directory) {
@@ -132,8 +139,17 @@ for (target in targets) {
132139
dockcrossTag = tag
133140
image = dockcrossImage
134141
containerName = "dockcross-${project.name}-$classifier"
142+
143+
if (ci) {
144+
doLast {
145+
exec {
146+
commandLine("docker", "image", "rm", "$repo:$tag")
147+
}
148+
}
149+
}
135150
}
136151

152+
137153
val packageNative = tasks.register("packageNativeFor$taskSuffix", Jar::class) {
138154
baseConfigure(compileNative, buildOutputDir.get())
139155

conventions/src/main/kotlin/tel.schich.javacan.convention.published.gradle.kts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ plugins {
44
`maven-publish`
55
}
66

7+
val ci = System.getenv("CI") != null
8+
79
java {
810
withSourcesJar()
911
withJavadocJar()
@@ -42,7 +44,9 @@ publishing {
4244
}
4345
}
4446

45-
signing {
46-
useGpgCmd()
47-
sign(publishing.publications)
47+
if (!ci) {
48+
signing {
49+
useGpgCmd()
50+
sign(publishing.publications)
51+
}
4852
}

0 commit comments

Comments
 (0)