diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b8bfe68 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release +on: + release: + types: + - released +jobs: + build: + name: Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: 'adopt' + java-version: '8' + + - uses: actions/cache@v4 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - uses: actions/cache@v4 + with: + path: ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradlew- + + - uses: crazy-max/ghaction-import-gpg@v6.1.0 + with: + gpg_private_key: "${{ secrets.GPG_PRIVATE_KEY }}" + passphrase: "${{ secrets.GPG_PASSPHRASE }}" + + - run: | + [[ "${{ github.event.release.tag_name }}" =~ ^[0-9]+(\.[0-9]+)*$ ]] || exit -1 + chmod +x gradlew + ./gradlew -Psign-required=true publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion="${{ github.event.release.tag_name }}" -Psigning.gnupg.keyName="${{ secrets.GPG_SECRET_KEY_ID }}" -Psigning.gnupg.passphrase="${{ secrets.GPG_PASSPHRASE }}" -PsonatypeUsername="${{ secrets.SONATYPE_USERNAME }}" -PsonatypePassword="${{ secrets.SONATYPE_PASSWORD }}" diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 0a34027..885a2f7 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -43,4 +43,4 @@ jobs: - run: | [[ "${{ steps.release.outputs.tag_name }}" =~ ^[0-9]+(\.[0-9]+)*$ ]] || exit -1 chmod +x gradlew - ./gradlew -Psign-required=true publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion="${{ steps.release.outputs.tag_name }}-SNAPSHOT" -PinfumiaSigningKey="${{ secrets.GPG_SECRET_KEY_ID }}" -PinfumiaSigningPassword="${{ secrets.GPG_PASSPHRASE }}" -PsonatypeUsername="${{ secrets.SONATYPE_USERNAME }}" -PsonatypePassword="${{ secrets.SONATYPE_PASSWORD }}" + ./gradlew -Psign-required=true publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion="${{ steps.release.outputs.tag_name }}-SNAPSHOT" -Psigning.gnupg.keyName="${{ secrets.GPG_SECRET_KEY_ID }}" -Psigning.gnupg.passphrase="${{ secrets.GPG_PASSPHRASE }}" -PsonatypeUsername="${{ secrets.SONATYPE_USERNAME }}" -PsonatypePassword="${{ secrets.SONATYPE_PASSWORD }}" diff --git a/.gitignore b/.gitignore index c27cedb..6fd8aba 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ build/ .settings/ **/bin/ .vscode/ +.kotlin/ diff --git a/build.gradle.kts b/build.gradle.kts index a415a7b..bb07343 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ plugins { java - alias(libs.plugins.indra.publishing.sonatype) + `maven-publish` + alias(libs.plugins.nexus) } repositories.mavenCentral() @@ -17,13 +18,35 @@ subprojects { } tasks { - compileJava { - options.compilerArgs.add("-Xlint:-processing") - options.compilerArgs.add("-Xlint:-options") + compileJava { options.encoding = Charsets.UTF_8.name() } + + javadoc { + options.encoding = Charsets.UTF_8.name() + (options as StandardJavadocDocletOptions).tags("todo") + } + + val javadocJar by creating(Jar::class) { + dependsOn("javadoc") + archiveClassifier.set("javadoc") + from(javadoc) + } + + val sourcesJar by creating(Jar::class) { + dependsOn("classes") + archiveClassifier.set("sources") + from(sourceSets["main"].allSource) + } + + build { + dependsOn(jar) + dependsOn(sourcesJar) + dependsOn(javadocJar) } } } -indraSonatype { - useAlternateSonatypeOSSHost("s01") +nexusPublishing.repositories.sonatype { + val baseUrl = "https://s01.oss.sonatype.org/" + nexusUrl = uri("${baseUrl}service/local/") + snapshotRepositoryUrl = uri("${baseUrl}content/repositories/snapshots/") } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index bf43e04..9eb26c7 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -7,7 +7,3 @@ repositories { mavenCentral() gradlePluginPortal() } - -dependencies { - implementation(libs.indra) -} diff --git a/buildSrc/src/main/kotlin/tr.com.infumia.pubsub.build.publishing.gradle.kts b/buildSrc/src/main/kotlin/tr.com.infumia.pubsub.build.publishing.gradle.kts index 6cffae7..b243e7e 100644 --- a/buildSrc/src/main/kotlin/tr.com.infumia.pubsub.build.publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/tr.com.infumia.pubsub.build.publishing.gradle.kts @@ -1,33 +1,53 @@ plugins { - id("net.kyori.indra") - id("net.kyori.indra.publishing") + signing + `maven-publish` } val projectName = project.property("artifact-id") as String +val signRequired = project.hasProperty("sign-required") -indra { - mitLicense() - github("infumia", "pubsub") - configurePublications { - artifactId = projectName +publishing { + publications { + val publication = create("maven") { + groupId = project.group.toString() + artifactId = projectName + version = project.version.toString() - pom { - name = projectName - inceptionYear = "2024" - description = "Simplified pubsub library for Redis and various databases." - developers { - developer { - name = "Hasan Demirtaş" - url = "https://github.com/portlek/" + from(components["java"]) + artifact(tasks["sourcesJar"]) + artifact(tasks["javadocJar"]) + + pom { + name.set(projectName) + description.set("Simplified pubsub library for Redis and various databases.") + url.set("https://github.com/Infumia/") + licenses { + license { + name.set("MIT License") + url.set("https://mit-license.org/license.txt") + } + } + developers { + developer { + id.set("portlek") + name.set("Hasan Demirtaş") + email.set("utsukushihito@outlook.com") + } + } + scm { + connection.set("scm:git:git://github.com/infumia/pubsub.git") + developerConnection.set("scm:git:ssh://github.com/infumia/pubsub.git") + url.set("https://github.com/infumia/pubsub/") } } - organization { - name = "Infumia" - url = "https://github.com/infumia/" + } + + signing { + isRequired = signRequired + if (isRequired) { + useGpgCmd() + sign(publication) } } } - if (project.hasProperty("sign-required")) { - signWithKeyFromPrefixedProperties("infumia") - } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5a4906a..3424dc3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,10 +10,8 @@ kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinserialization" } kotlinx-serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "kotlinserialization" } -indra = { module = "net.kyori:indra-common", version.ref = "indra" } - [plugins] kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } dokka = { id = "org.jetbrains.dokka", version = "1.9.20" } -indra-publishing-sonatype = { id = "net.kyori.indra.publishing.sonatype", version.ref = "indra" } +nexus = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" }