Skip to content

Commit

Permalink
first attempt at CI with gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
pschichtel committed Jul 3, 2024
1 parent 2a5dc3e commit b873690
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/maven.yml → .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
with:
java-version: '8'
distribution: 'temurin'
cache: maven
cache: gradle
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Build with Maven
run: ./mvnw -B package deploy -Djavacan.compile-script="$PWD/ci/compile-native.sh" -Pall-architectures,android
- name: Build
run: ./gradlew publish
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.gradle.configurationcache.extensions.capitalized
import tel.schich.dockcross.execute.DockerRunner
import tel.schich.dockcross.execute.NonContainerRunner
import tel.schich.dockcross.tasks.DockcrossRunTask

Expand All @@ -7,6 +8,8 @@ plugins {
id("tel.schich.dockcross")
}

val ci = System.getenv("CI") != null

val archDetectConfiguration by configurations.registering {
isCanBeConsumed = true
}
Expand Down Expand Up @@ -98,6 +101,10 @@ fun DockcrossRunTask.baseConfigure(linkMode: NativeLinkMode, outputTo: Directory
listOf("cmake", relativePathToProject, projectVersionOption, releaseOption, linkStaticallyOption),
listOf("make", "-j${project.gradle.startParameter.maxWorkerCount}"),
)

if (ci) {
runner(DockerRunner())
}
}

fun Jar.baseConfigure(compileTask: TaskProvider<DockcrossRunTask>, buildOutputDir: Directory) {
Expand Down Expand Up @@ -132,8 +139,17 @@ for (target in targets) {
dockcrossTag = tag
image = dockcrossImage
containerName = "dockcross-${project.name}-$classifier"

if (ci) {
doLast {
exec {
commandLine("docker", "image", "rm", "$repo:$tag")
}
}
}
}


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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ plugins {
`maven-publish`
}

val ci = System.getenv("CI") != null

java {
withSourcesJar()
withJavadocJar()
Expand Down Expand Up @@ -42,7 +44,9 @@ publishing {
}
}

signing {
useGpgCmd()
sign(publishing.publications)
if (!ci) {
signing {
useGpgCmd()
sign(publishing.publications)
}
}

0 comments on commit b873690

Please sign in to comment.