Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to jreleaser #7

Merged
merged 9 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,33 @@ jobs:
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.GITHUBTOKEN }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeUser: ${{ secrets.SONATYPE_USER }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: ./gradlew -Pversion=$VERSION build sourcesJar dokkaGeneratePublicationHtml publishToSonatype closeAndReleaseSonatypeStagingRepository
JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
run: ./gradlew -Pversion=$VERSION build sourcesJar dokkaGeneratePublicationHtml publish jreleaserDeploy

- name: Checkout main branch
- name: Display JReleaser trace.log (only on failure)
if: failure()
run: |
if [ -f build/jreleaser/trace.log ]; then
echo "trace.log Content:"
tail -1000 build/jreleaser/trace.log
else
echo "trace.log file not found"
fi

- name: Checkout main branch (only if releasing from main)
if: github.ref == 'refs/heads/main'
uses: actions/[email protected]
with:
ref: main
fetch-depth: 0

- name: Update README
- name: Update README (only if releasing from main)
if: github.ref == 'refs/heads/main'
run: sh .github/scripts/update-readme-version.sh

- name: Create Pull Request
- name: Create Pull Request (only if releasing from main)
if: github.ref == 'refs/heads/main'
uses: stefanzweifel/[email protected]
with:
commit_message: Dependency version in README.md updated to ${{ env.VERSION }}
Expand Down
146 changes: 94 additions & 52 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import org.jetbrains.kotlin.gradle.swiftexport.ExperimentalSwiftExportDsl
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
import org.jreleaser.model.Active
import java.time.LocalDate

plugins {
alias(libs.plugins.kotlin.multiplatform)
Expand All @@ -19,10 +21,20 @@ plugins {
alias(libs.plugins.versions)
`maven-publish`
signing
alias(libs.plugins.publish)
alias(libs.plugins.jreleaser)
}

val githubAccount = "xemantic"
data class Settings(
val description: String,
val gitHubAccount: String,
val copyright: String
)

val settings = Settings(
description = "The power-assert compatible assertions DSL and some other testing goodies - a Kotlin multiplatform testing library",
gitHubAccount = "xemantic",
copyright = "(c) ${LocalDate.now().year} Xemantic"
)

val javaTarget = libs.versions.javaTarget.get()
val kotlinTarget = KotlinVersion.fromVersion(libs.versions.kotlinTarget.get())
Expand All @@ -32,8 +44,6 @@ val githubActor: String? by project
val githubToken: String? by project
val signingKey: String? by project
val signingPassword: String? by project
val sonatypeUser: String? by project
val sonatypePassword: String? by project

println(
"""
Expand Down Expand Up @@ -181,7 +191,7 @@ powerAssert {
// https://kotlinlang.org/docs/dokka-migration.html#adjust-configuration-options
dokka {
pluginsConfiguration.html {
footerMessage.set("(c) 2024 Xemantic")
footerMessage.set(settings.copyright)
}
}

Expand All @@ -190,12 +200,18 @@ val javadocJar by tasks.registering(Jar::class) {
from(tasks.dokkaGeneratePublicationHtml)
}

val stagingDeployDir = layout.buildDirectory.dir("staging-deploy").get().asFile

publishing {
repositories {
if (!isReleaseBuild) {
if (isReleaseBuild) {
maven {
url = stagingDeployDir.toURI()
}
} else {
maven {
name = "GitHubPackages"
setUrl("https://maven.pkg.github.com/$githubAccount/${rootProject.name}")
setUrl("https://maven.pkg.github.com/${settings.gitHubAccount}/${rootProject.name}")
credentials {
username = githubActor
password = githubToken
Expand All @@ -206,50 +222,22 @@ publishing {
publications {
withType<MavenPublication> {
artifact(javadocJar)
pom {
name = "xemantic-kotlin-test"
description = "The power-assert compatible assertions DSL and some other testing goodies - " +
"a Kotlin multiplatform testing library."
url = "https://github.com/$githubAccount/${rootProject.name}"
inceptionYear = "2024"
organization {
name = "Xemantic"
url = "https://xemantic.com"
}
licenses {
license {
name = "The Apache Software License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "repo"
}
}
scm {
url = "https://github.com/$githubAccount/${rootProject.name}"
connection = "scm:git:git:github.com/$githubAccount/${rootProject.name}.git"
developerConnection = "scm:git:https://github.com/$githubAccount/${rootProject.name}.git"
}
ciManagement {
system = "GitHub"
url = "https://github.com/$githubAccount/${rootProject.name}/actions"
}
issueManagement {
system = "GitHub"
url = "https://github.com/$githubAccount/${rootProject.name}/issues"
}
developers {
developer {
id = "morisil"
name = "Kazik Pogoda"
email = "[email protected]"
}
}
}
pom { setUpPomDetails() }
}
}
}

if (isReleaseBuild) {

tasks.named("jreleaserDeploy").configure {
mustRunAfter("publish")
}

stagingDeployDir.mkdirs()

// fixes https://github.com/jreleaser/jreleaser/issues/1292
layout.buildDirectory.dir("jreleaser").get().asFile.mkdir()

// workaround for KMP/gradle signing issue
// https://github.com/gradle/gradle/issues/26091
tasks {
Expand Down Expand Up @@ -284,15 +272,69 @@ if (isReleaseBuild) {
sign(publishing.publications)
}

nexusPublishing {
repositories {
sonatype { //only for users registered in Sonatype after 24 Feb 2021
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(sonatypeUser)
password.set(sonatypePassword)
jreleaser {
project {
description = settings.description
copyright = settings.copyright
}
deploy {
maven {
mavenCentral {
create("maven-central") {
applyMavenCentralRules = false // Already checked
active = Active.ALWAYS
url = "https://central.sonatype.com/api/v1/publisher"
maxRetries = 240
stagingRepository(stagingDeployDir.path)
}
}
}
}
release {
github {
// we are releasing through GitHub UI
skipRelease = true
skipTag = true
}
}
}

}

fun MavenPom.setUpPomDetails() {
name = rootProject.name
description = settings.description
url = "https://github.com/${settings.gitHubAccount}/${rootProject.name}"
inceptionYear = "2024"
organization {
name = "Xemantic"
url = "https://xemantic.com"
}
licenses {
license {
name = "The Apache Software License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "repo"
}
}
scm {
url = "https://github.com/${settings.gitHubAccount}/${rootProject.name}"
connection = "scm:git:git:github.com/${settings.gitHubAccount}/${rootProject.name}.git"
developerConnection = "scm:git:https://github.com/${settings.gitHubAccount}/${rootProject.name}.git"
}
ciManagement {
system = "GitHub"
url = "https://github.com/${settings.gitHubAccount}/${rootProject.name}/actions"
}
issueManagement {
system = "GitHub"
url = "https://github.com/${settings.gitHubAccount}/${rootProject.name}/issues"
}
developers {
developer {
id = "morisil"
name = "Kazik Pogoda"
email = "[email protected]"
}
}
}
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ kotlin = "2.1.0"

versionsPlugin = "0.51.0"
dokkaPlugin = "2.0.0"
publishPlugin = "2.0.0"
jreleaserPlugin = "1.16.0"

binaryCompatibilityValidatorPlugin = "0.17.0"

Expand All @@ -18,5 +18,5 @@ kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref
kotlin-plugin-power-assert = { id = "org.jetbrains.kotlin.plugin.power-assert", version.ref = "kotlin" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokkaPlugin" }
versions = { id = "com.github.ben-manes.versions", version.ref = "versionsPlugin" }
publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "publishPlugin" }
kotlinx-binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binaryCompatibilityValidatorPlugin" }
jreleaser = { id = "org.jreleaser", version.ref = "jreleaserPlugin" }
Loading