adapt for workflow

This commit is contained in:
Fokinator
2026-06-02 13:59:35 +03:00
parent c9a082320d
commit 1bd32119b6
4 changed files with 173 additions and 88 deletions
+38
View File
@@ -0,0 +1,38 @@
name: Publish Release
on:
push:
branches:
- release
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: 25
distribution: 'temurin'
# GPG setup for signing
gpg-private-key: ${{ secrets.SIGNING_KEY }}
gpg-passphrase: ${{ secrets.SIGNING_PASSWORD }}
- name: Make Gradle executable
run: chmod +x ./gradlew
- name: Check JAVA_HOME
run: echo $JAVA_HOME
- name: Build, Test, Publish
run: ./gradlew test publish -Djava.awt.headless=true
env:
# OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
# OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
# GITHUB_ACTOR: ${{ secrets.ACTOR }}
# GITHUB_TOKEN: ${{ secrets.TOKEN }}
GITEA_TOKEN: ${{ secrets.TOKEN }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
+132 -85
View File
@@ -1,4 +1,5 @@
import static org.apache.tools.ant.taskdefs.condition.Os.*
import static groovy.lang.Tuple.tuple
plugins {
id 'java'
@@ -17,8 +18,8 @@ To run Sparkle, you only need this module; if you want additional functionality,
'$group'."""
repositories {
mavenLocal()
mavenCentral()
add(mavenCentral())
add(mavenLocal())
}
java {
@@ -26,21 +27,36 @@ java {
targetCompatibility = 25
}
sourceSets.register('natives')
def lombokVersion = "1.18.44"
def lwjglVersion = "3.4.1"
def lwjglNatives = findLWJGLNatives()
def lwjglVersionNatives = "$lwjglVersion:$lwjglNatives"
def lwjglNativeLibs = [
"org.lwjgl:lwjgl:$lwjglVersionNatives",
"org.lwjgl:lwjgl-glfw:$lwjglVersionNatives",
"org.lwjgl:lwjgl-nanovg:$lwjglVersionNatives",
"org.lwjgl:lwjgl-openal:$lwjglVersionNatives",
"org.lwjgl:lwjgl-opengl:$lwjglVersionNatives",
"org.lwjgl:lwjgl-stb:$lwjglVersionNatives"
def lwjglNativesAll = [
'windows': tuple('nativesWindows', 'Windows x64', '*.dll'),
'linux': tuple('nativesLinux', 'Linux x64', '*.so'),
'macos-arm64': tuple('nativesMacOSArm64', 'macOS arm64', '*.dylib'),
'macos': tuple('nativesMacOS', 'macOS x86_64', '*.dylib'),
]
def lwjglNativesCurrent = findLWJGLNatives()
def lwjglNativeLibsCurrent = [
"org.lwjgl:lwjgl:$lwjglVersion:$lwjglNativesCurrent",
"org.lwjgl:lwjgl-glfw:$lwjglVersion:$lwjglNativesCurrent",
"org.lwjgl:lwjgl-nanovg:$lwjglVersion:$lwjglNativesCurrent",
"org.lwjgl:lwjgl-openal:$lwjglVersion:$lwjglNativesCurrent",
"org.lwjgl:lwjgl-opengl:$lwjglVersion:$lwjglNativesCurrent",
"org.lwjgl:lwjgl-stb:$lwjglVersion:$lwjglNativesCurrent"
]
List<String> lwjglNativeLibsAll = []
lwjglNativesAll.each {
sourceSets.register(it.value.v1)
def classifier = "natives-$it.key"
lwjglNativeLibsAll.addAll([
"org.lwjgl:lwjgl:$lwjglVersion:$classifier",
"org.lwjgl:lwjgl-glfw:$lwjglVersion:$classifier",
"org.lwjgl:lwjgl-nanovg:$lwjglVersion:$classifier",
"org.lwjgl:lwjgl-openal:$lwjglVersion:$classifier",
"org.lwjgl:lwjgl-opengl:$lwjglVersion:$classifier",
"org.lwjgl:lwjgl-stb:$lwjglVersion:$classifier"
])
}
dependencies {
implementation 'it.unimi.dsi:fastutil:8.5.15'
@@ -57,7 +73,7 @@ dependencies {
runtimeOnly 'ch.qos.logback:logback-classic:1.5.18' // SLF4J implementation
lwjglNativeLibs.forEach {lib ->
lwjglNativeLibsAll.forEach {lib ->
compileOnly lib
}
compileOnly "org.projectlombok:lombok:$lombokVersion"
@@ -68,7 +84,7 @@ dependencies {
testRuntimeOnly 'ch.qos.logback:logback-classic:1.5.18' // SLF4J implementation
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:6.1.0'
lwjglNativeLibs.forEach {lib ->
lwjglNativeLibsCurrent.forEach {lib ->
testRuntimeOnly lib
}
@@ -103,62 +119,49 @@ processTestResources {
}
}
tasks.register('generateNativesModule') {
tasks.register('generateNativesModules') {
doLast {
println "OS Name: ${System.getProperty('os.name')}"
println "OS Arch: ${System.getProperty('os.arch')}"
println "LWJGL natives: $lwjglNatives"
def nativesNameLower = lwjglNatives.replace('natives-', '').replace('-', '.')
def nativesName = String.valueOf(nativesNameLower.charAt(0)).toUpperCase(Locale.ENGLISH) + nativesNameLower.substring(1)
def sourcesDir = new File(temporaryDir, 'java')
def resourcesDir = new File(temporaryDir, 'resources')
lwjglNativesAll.each { entry ->
def nativesNameLower = entry.key
def sourceSetName = entry.value.v1
def nativesNameFriendly = entry.value.v2
def sourcesDir = new File(temporaryDir, "$sourceSetName/java")
def resourcesDir = new File(temporaryDir, "$sourceSetName/resources")
copy {
from new File(projectDir, '/src/nativeTemplate/java')
into sourcesDir
copy {
from new File(projectDir, '/src/nativeTemplate/java')
into sourcesDir
filter { String line ->
line
.replace('NATIVES_NAME_LOWER', nativesNameLower)
.replace('NATIVES_NAME', nativesName)
filter { String line ->
line
.replace('NATIVES_NAME_LOWER_NODASH', nativesNameLower.replace('-', '.'))
.replace('NATIVES_NAME_LOWER', nativesNameLower)
.replace('NATIVES_NAME_FRIENDLY', nativesNameFriendly)
}
include '**/*.java'
}
include '**/*.java'
}
sourceSets.named(sourceSetName).get().java.srcDir sourcesDir
sourceSets.natives.java.srcDir sourcesDir
def nativesDir = new File(resourcesDir, "natives/$nativesNameLower")
sourceSets.main.compileClasspath.files.each { jar ->
if (jar.name.contains('natives')) {
copy {
from zipTree(jar).files // flatten
include '*.so', '*.dll', '*.dylib'
into nativesDir
def nativesDir = new File(resourcesDir, "natives/$nativesNameLower")
sourceSets.main.compileClasspath.files.each { jar ->
if (jar.name.contains("natives-$nativesNameLower")) {
copy {
from zipTree(jar).files // flatten
include '*.dll', '*.so', '*.dylib'
into nativesDir
}
}
}
sourceSets.named(sourceSetName).get().resources.srcDir resourcesDir
}
sourceSets.natives.resources.srcDir resourcesDir
}
}
compileNativesJava {
dependsOn generateNativesModule, jar
doFirst {
def coreJar = files(new File(layout.buildDirectory.get().asFile, "libs/${project.name}-${version}.jar"))
sourceSets.natives.compileClasspath += coreJar
sourceSets.natives.runtimeClasspath += coreJar
classpath += coreJar
}
}
processNativesResources {
dependsOn generateNativesModule
}
jar {
dependsOn compileJava
dependsOn compileJava, processResources
from compileJava.destinationDirectory.get().asFile, processResources.destinationDir
}
@@ -167,34 +170,71 @@ tasks.register('jarSources', Jar) {
from sourceSets.main.java.asFileTree
}
tasks.register('jarNatives', Jar) {
dependsOn compileNativesJava, processNativesResources
archiveClassifier = lwjglNatives
from compileNativesJava.destinationDirectory.get().asFile, processNativesResources.destinationDir
lwjglNativesAll.each { entry ->
def sourceSetName = entry.value.v1
def sourceSetNameUpper = sourceSetName.substring(0, 1).toUpperCase(Locale.ENGLISH) + sourceSetName.substring(1)
def compile = tasks.named("compile${sourceSetNameUpper}Java") {
dependsOn generateNativesModules, jar
doFirst {
def coreJar = files(jar.archiveFile.get().asFile)
classpath += coreJar
}
}.get() as JavaCompile
def resources = tasks.named("process${sourceSetNameUpper}Resources") {
dependsOn generateNativesModules
}.get() as ProcessResources
tasks.register("jar${sourceSetNameUpper}", Jar) {
dependsOn compile, resources
archiveClassifier = "natives-$entry.key"
from compile.destinationDirectory.get().asFile, resources.destinationDir
}
}
tasks.register('jarNativesAll') {
lwjglNativesAll.each { entry ->
def sourceSetName = entry.value.v1
def sourceSetNameUpper = sourceSetName.substring(0, 1).toUpperCase(Locale.ENGLISH) + sourceSetName.substring(1)
dependsOn "jar$sourceSetNameUpper"
}
}
assemble {
dependsOn jarSources, jarNatives
dependsOn jar, jarSources, jarNativesAll
}
def project = project // prevent 'cannot resolve' warnings
publishing {
repositories {
// maven {
// name = 'Central'
// url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
// credentials {
// username = project.findProperty('ossrh.username') ?: System.getenv('OSSRH_USERNAME')
// password = project.findProperty('ossrh.password') ?: System.getenv('OSSRH_PASSWORD')
// }
// }
// maven {
// name = 'GitHubPackages'
// url = 'https://maven.pkg.github.com/SparkleJ-Framework/sparkle-core'
// credentials {
// username = project.findProperty('gpr.user') ?: System.getenv('GITHUB_ACTOR')
// password = project.findProperty('gpr.token') ?: System.getenv('GITHUB_TOKEN')
// }
// }
maven {
name = 'Central'
url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
credentials {
username = project.findProperty('ossrh.username') ?: System.getenv('OSSRH_USERNAME')
password = project.findProperty('ossrh.password') ?: System.getenv('OSSRH_PASSWORD')
name = 'GiteaPackages'
url = 'https://gitea.darktale.keenetic.link/api/packages/michael/maven'
credentials(HttpHeaderCredentials) {
name 'Authorization'
value "token ${project.findProperty('giteaAccessToken') ?: System.getenv('GITEA_TOKEN')}"
}
}
maven {
name = 'GitHubPackages'
url = 'https://maven.pkg.github.com/SparkleJ-Framework/sparkle-core'
credentials {
username = project.findProperty('gpr.user') ?: System.getenv('GITHUB_ACTOR')
password = project.findProperty('gpr.token') ?: System.getenv('GITHUB_TOKEN')
authentication {
register('header', HttpHeaderAuthentication)
}
}
}
@@ -227,20 +267,27 @@ publishing {
artifact(jarSources) {
classifier = 'sources'
}
artifact(jarNatives) {
classifier = lwjglNatives
lwjglNativesAll.each { entry ->
def sourceSetName = entry.value.v1
def sourceSetNameUpper = sourceSetName.substring(0, 1).toUpperCase(Locale.ENGLISH) + sourceSetName.substring(1)
artifact(project.tasks.named("jar$sourceSetNameUpper").get()) {
classifier = "natives-$entry.key"
}
}
}
}
}
//signing {
// useInMemoryPgpKeys(
// project.findProperty('signingKey').toString() ?: System.getenv('SIGNING_KEY'),
// project.findProperty('signingPassword').toString() ?: System.getenv('SIGNING_PASSWORD')
// )
// sign publishing.publications
//}
def key = project.findProperty('signingKey').toString() ?: System.getenv('SIGNING_KEY')
def password = project.findProperty('signingPassword').toString() ?: System.getenv('SIGNING_PASSWORD')
if (key != "null" && password != "null") {
signing {
useInMemoryPgpKeys(key, password)
sign publishing.publications
}
} else {
logger.log(LogLevel.WARN, 'Signing disabled: no key or password specified')
}
static String findLWJGLNatives() {
String lwjglNatives = null
+2 -2
View File
@@ -1,7 +1,7 @@
/**
* Native library provider for NATIVES_NAME.
* Native library provider for NATIVES_NAME_FRIENDLY.
*/
module net.fokinatorr.sparkle.core.natives.NATIVES_NAME_LOWER {
module net.fokinatorr.sparkle.core.natives.NATIVES_NAME_LOWER_NODASH {
requires net.fokinatorr.sparkle.core;
provides net.fokinatorr.sparkle.NativeExtractor with net.fokinatorr.sparkle.natives.NativeExtractorImpl;
@@ -33,7 +33,7 @@ public class NativeExtractorImpl implements NativeExtractor {
try {
jarFs.close();
} catch (Exception e) {
System.err.print("[NativeExtractor NATIVES_NAME] Failed to close JAR filesystem: ");
System.err.print("[NativeExtractor NATIVES_NAME_FRIENDLY] Failed to close JAR filesystem: ");
e.printStackTrace();
}
}));