diff --git a/.github/workflows/cross.yml b/.github/workflows/cross.yml index 7beba8cb..010d7454 100644 --- a/.github/workflows/cross.yml +++ b/.github/workflows/cross.yml @@ -7,6 +7,12 @@ on: pull_request: branches: - main + workflow_dispatch: + inputs: + run_optional_task: + description: 'Publish?' + required: false + default: 'false' jobs: @@ -280,7 +286,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: surrealdb - path: build/libs/surrealdb-1.0.0-beta.1.jar + path: build/libs/surrealdb-1.0.0-SNAPSHOT.jar - name: Linux Integration Test run: ./gradlew -i integrationTest @@ -306,14 +312,14 @@ jobs: - name: Gradle run: chmod +x gradlew - - name: Create directory build/libs - run: mkdir -p build/libs + - name: Create directory native + run: mkdir -p native - name: Download JAR uses: actions/download-artifact@v4 with: name: surrealdb - path: build/libs + path: native - name: Tests run: ./gradlew -i integrationTest @@ -322,7 +328,7 @@ jobs: needs: - aggregated-jar - integration-tests - if: github.ref == 'refs/heads/main' + if: github.event_name == 'workflow_dispatch' && github.event.inputs.run_optional_task == 'true' runs-on: ubuntu-latest permissions: contents: read @@ -336,11 +342,14 @@ jobs: distribution: 'temurin' java-version: 22 + - name: Create directory native + run: mkdir -p native + - name: Download JAR uses: actions/download-artifact@v4 with: name: surrealdb - path: build/libs + path: native - name: Publish Jar (Maven) run: ./gradlew publish @@ -349,13 +358,4 @@ jobs: MAVEN_USERNAME: ${{ secrets.OSSRH_USER }} MAVEN_PASSWORD: ${{ secrets.OSSRH_PASS }} SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - SIGNING_KEY_PASS: ${{ secrets.SIGNING_KEY_PASS }} - - - name: Publish release package - uses: softprops/action-gh-release@v2 - if: github.event_name == 'release' && github.event.action == 'created' - with: - name: "Release ${{ github.ref_name }}" - files: | - LICENSE - build/libs/*.jar \ No newline at end of file + SIGNING_KEY_PASS: ${{ secrets.SIGNING_KEY_PASS }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 482b5ce2..22b70e23 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,5 @@ hs_err_*.log /out/ # Ignore specific Gradle caches and logs -.gradle/ \ No newline at end of file +.gradle/ +/native \ No newline at end of file diff --git a/README.md b/README.md index 62d83fcf..48bb2d28 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Gradle: ```groovy ext { - surrealdbVersion = "1.0.0-SNAPSHOT" + surrealdbVersion = "1.0.0-beta.1" } dependencies { @@ -80,7 +80,7 @@ Maven: com.surrealdb surrealdb - 1.0.0-SNAPSHOT + 1.0.0-beta.1 ``` diff --git a/build.gradle b/build.gradle index 602a7933..bb5b6c5d 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ plugins { } group 'com.surrealdb' -version '1.0.0-beta.1' +version '1.0.0-SNAPSHOT' repositories { mavenCentral() @@ -31,9 +31,68 @@ configurations { integrationTestRuntimeOnly.extendsFrom testRuntimeOnly } +ext.nativeJar = file("native/surrealdb-${version}.jar") + +// Fail fast, but only when the task graph contains a task that needs the file +gradle.taskGraph.whenReady { graph -> + boolean needsNativeJar = graph.allTasks.any { t -> + t.name in ['publish', 'publishToMavenLocal'] || + (t.name.startsWith('generate') && t.name.endsWith('Publication')) + } + + + + if (needsNativeJar && !nativeJar.exists()) { + throw new GradleException( + "Native JAR not found at '${nativeJar}'. " + + "Build/copy it to native/ before running publishing tasks." + ) + } +} + + + +// --------------------------------------------------------------------------- +// 2. Task that stages (copies) the external JAR into build/libs +// --------------------------------------------------------------------------- +tasks.register('stageNativeJar', Copy) { + description = 'Copies the externally built JAR (with native libs) into build/libs.' + group = 'build' + + from nativeJar + into "$buildDir/libs" + rename { "surrealdb-${version}.jar" } // the file name expected by publish/sign +} + +// --------------------------------------------------------------------------- +// 3. Make sure every task that cares about the JAR sees the staged version. +// • jar is still executed (keeps components.java happy), but the copy task +// will overwrite its output afterwards. +// --------------------------------------------------------------------------- +tasks.named('jar') { + finalizedBy 'stageNativeJar' // run jar first, then overwrite +} + +// All publish-to-Maven tasks must wait for the staged JAR +tasks.withType(PublishToMavenRepository).configureEach { + dependsOn 'stageNativeJar' +} +// Metadata / POM generation tasks must wait as well +tasks.matching { it.name.startsWith('generate') && it.name.endsWith('Publication') } + .configureEach { dependsOn 'stageNativeJar' } + +// The generated signing task is created after evaluation; use task rules +tasks.matching { it.name == 'signMavenJavaPublication' }.configureEach { + dependsOn 'stageNativeJar' +} + + dependencies { testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2' - integrationTestImplementation files("build/libs/surrealdb-1.0.0-beta.1.jar") + // classes produced by src/main/java + integrationTestImplementation sourceSets.main.output + // the staged, native-enabled JAR + integrationTestImplementation files("native/surrealdb-${version}.jar") } jacoco { @@ -63,10 +122,6 @@ jacocoTestCoverageVerification { } } -artifacts { - archives javadocJar, sourcesJar -} - tasks.register('createCombinedReport') { dependsOn jacocoTestReport dependsOn javadoc @@ -103,10 +158,13 @@ tasks.register('createCombinedReport') { } } + tasks.register('integrationTest', Test) { + dependsOn 'stageNativeJar' useJUnitPlatform() testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath + // use target/release for a release build testLogging { showStandardStreams = true events "passed", "skipped", "failed", "standardOut", "standardError" @@ -136,16 +194,16 @@ publishing { password = System.getenv("GITHUB_TOKEN") } } -// maven { -// name = "OSSRH" -// def releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") -// def snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") -// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl -// credentials { -// username = System.getenv("MAVEN_USERNAME") -// password = System.getenv("MAVEN_PASSWORD") -// } -// } + maven { + name = "OSSRH" + def releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") + def snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + credentials { + username = System.getenv("MAVEN_USERNAME") + password = System.getenv("MAVEN_PASSWORD") + } + } } publications {