Skip to content

Commit 36f5783

Browse files
Prepare 1.0.0-beta.1 (#117)
1 parent 3daeac4 commit 36f5783

File tree

3 files changed

+90
-31
lines changed

3 files changed

+90
-31
lines changed

.github/workflows/cross.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ on:
77
pull_request:
88
branches:
99
- main
10+
workflow_dispatch:
11+
inputs:
12+
run_optional_task:
13+
description: 'Publish?'
14+
required: false
15+
default: 'false'
1016

1117
jobs:
1218

@@ -306,14 +312,14 @@ jobs:
306312
- name: Gradle
307313
run: chmod +x gradlew
308314

309-
- name: Create directory build/libs
310-
run: mkdir -p build/libs
315+
- name: Create directory native
316+
run: mkdir -p native
311317

312318
- name: Download JAR
313319
uses: actions/download-artifact@v4
314320
with:
315321
name: surrealdb
316-
path: build/libs
322+
path: native
317323

318324
- name: Tests
319325
run: ./gradlew -i integrationTest
@@ -322,7 +328,7 @@ jobs:
322328
needs:
323329
- aggregated-jar
324330
- integration-tests
325-
if: github.ref == 'refs/heads/main'
331+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.run_optional_task == 'true'
326332
runs-on: ubuntu-latest
327333
permissions:
328334
contents: read
@@ -336,11 +342,14 @@ jobs:
336342
distribution: 'temurin'
337343
java-version: 22
338344

345+
- name: Create directory native
346+
run: mkdir -p native
347+
339348
- name: Download JAR
340349
uses: actions/download-artifact@v4
341350
with:
342351
name: surrealdb
343-
path: build/libs
352+
path: native
344353

345354
- name: Publish Jar (Maven)
346355
run: ./gradlew publish
@@ -349,13 +358,4 @@ jobs:
349358
MAVEN_USERNAME: ${{ secrets.OSSRH_USER }}
350359
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASS }}
351360
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
352-
SIGNING_KEY_PASS: ${{ secrets.SIGNING_KEY_PASS }}
353-
354-
- name: Publish release package
355-
uses: softprops/action-gh-release@v2
356-
if: github.event_name == 'release' && github.event.action == 'created'
357-
with:
358-
name: "Release ${{ github.ref_name }}"
359-
files: |
360-
LICENSE
361-
build/libs/*.jar
361+
SIGNING_KEY_PASS: ${{ secrets.SIGNING_KEY_PASS }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ hs_err_*.log
2525
/out/
2626

2727
# Ignore specific Gradle caches and logs
28-
.gradle/
28+
.gradle/
29+
/native

build.gradle

Lines changed: 73 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,68 @@ configurations {
3131
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
3232
}
3333

34+
ext.nativeJar = file("native/surrealdb-${version}.jar")
35+
36+
// Fail fast, but only when the task graph contains a task that needs the file
37+
gradle.taskGraph.whenReady { graph ->
38+
boolean needsNativeJar = graph.allTasks.any { t ->
39+
t.name in ['publish', 'publishToMavenLocal'] ||
40+
(t.name.startsWith('generate') && t.name.endsWith('Publication'))
41+
}
42+
43+
44+
45+
if (needsNativeJar && !nativeJar.exists()) {
46+
throw new GradleException(
47+
"Native JAR not found at '${nativeJar}'. " +
48+
"Build/copy it to native/ before running publishing tasks."
49+
)
50+
}
51+
}
52+
53+
54+
55+
// ---------------------------------------------------------------------------
56+
// 2. Task that stages (copies) the external JAR into build/libs
57+
// ---------------------------------------------------------------------------
58+
tasks.register('stageNativeJar', Copy) {
59+
description = 'Copies the externally built JAR (with native libs) into build/libs.'
60+
group = 'build'
61+
62+
from nativeJar
63+
into "$buildDir/libs"
64+
rename { "surrealdb-${version}.jar" } // the file name expected by publish/sign
65+
}
66+
67+
// ---------------------------------------------------------------------------
68+
// 3. Make sure every task that cares about the JAR sees the staged version.
69+
// • jar is still executed (keeps components.java happy), but the copy task
70+
// will overwrite its output afterwards.
71+
// ---------------------------------------------------------------------------
72+
tasks.named('jar') {
73+
finalizedBy 'stageNativeJar' // run jar first, then overwrite
74+
}
75+
76+
// All publish-to-Maven tasks must wait for the staged JAR
77+
tasks.withType(PublishToMavenRepository).configureEach {
78+
dependsOn 'stageNativeJar'
79+
}
80+
// Metadata / POM generation tasks must wait as well
81+
tasks.matching { it.name.startsWith('generate') && it.name.endsWith('Publication') }
82+
.configureEach { dependsOn 'stageNativeJar' }
83+
84+
// The generated signing task is created after evaluation; use task rules
85+
tasks.matching { it.name == 'signMavenJavaPublication' }.configureEach {
86+
dependsOn 'stageNativeJar'
87+
}
88+
89+
3490
dependencies {
3591
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
36-
integrationTestImplementation files("build/libs/surrealdb-1.0.0-beta.1.jar")
92+
// classes produced by src/main/java
93+
integrationTestImplementation sourceSets.main.output
94+
// the staged, native-enabled JAR
95+
integrationTestImplementation files("native/surrealdb-${version}.jar")
3796
}
3897

3998
jacoco {
@@ -63,10 +122,6 @@ jacocoTestCoverageVerification {
63122
}
64123
}
65124

66-
artifacts {
67-
archives javadocJar, sourcesJar
68-
}
69-
70125
tasks.register('createCombinedReport') {
71126
dependsOn jacocoTestReport
72127
dependsOn javadoc
@@ -103,10 +158,13 @@ tasks.register('createCombinedReport') {
103158
}
104159
}
105160

161+
106162
tasks.register('integrationTest', Test) {
163+
dependsOn 'stageNativeJar'
107164
useJUnitPlatform()
108165
testClassesDirs = sourceSets.integrationTest.output.classesDirs
109166
classpath = sourceSets.integrationTest.runtimeClasspath
167+
// use target/release for a release build
110168
testLogging {
111169
showStandardStreams = true
112170
events "passed", "skipped", "failed", "standardOut", "standardError"
@@ -136,16 +194,16 @@ publishing {
136194
password = System.getenv("GITHUB_TOKEN")
137195
}
138196
}
139-
// maven {
140-
// name = "OSSRH"
141-
// def releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
142-
// def snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
143-
// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
144-
// credentials {
145-
// username = System.getenv("MAVEN_USERNAME")
146-
// password = System.getenv("MAVEN_PASSWORD")
147-
// }
148-
// }
197+
maven {
198+
name = "OSSRH"
199+
def releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
200+
def snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
201+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
202+
credentials {
203+
username = System.getenv("MAVEN_USERNAME")
204+
password = System.getenv("MAVEN_PASSWORD")
205+
}
206+
}
149207
}
150208

151209
publications {

0 commit comments

Comments
 (0)