Skip to content

Commit

Permalink
ci: publishing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dogacel committed Aug 10, 2024
1 parent 668d2cd commit 716d932
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Ignore Gradle build output directory
build

.kls_database.db
.idea

.DS_Store
.DS_Store
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ Focusing on core functionality, here is a list of known major issues:
- [x] Generated `enum` fields with negative values can't be serialized / deserialized.
- [ ] Make data classes with `ByteArray` implement equals and hashcode correctly.

## Releasing

1. Make sure you set `SONATYPE_USERNAME`, `SONATYPE_PASSWORD`, `GPG_SIGNING_KEY` and `GPG_SIGNING_PASSPHRASE`.
2. `./gradlew publishToSonatype`
3. `./gradlew findSonatypeStagingRepository closeSonatypeStagingRepository`
4. `./gradlew findSonatypeStagingRepository releaseSonatypeStagingRepository`

## Contribution

For starters, start by checking [issues](./issues).
Expand Down
19 changes: 18 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ plugins {
kotlin("plugin.serialization")
id("com.google.protobuf")
application
`maven-publish`
id("org.jetbrains.dokka")
id("org.jetbrains.kotlinx.kover")

// Publish
`maven-publish`
signing
}

repositories {
Expand Down Expand Up @@ -154,3 +157,17 @@ publishing {
}
}
}

signing {
val signingKey = providers.environmentVariable("GPG_SIGNING_KEY")
val signingPassphrase = providers.environmentVariable("GPG_SIGNING_PASSPHRASE")

if (signingKey.isPresent && signingPassphrase.isPresent) {
useInMemoryPgpKeys(
signingKey.get(),
signingPassphrase.get(),
)
val extension = extensions.getByName("publishing") as PublishingExtension
sign(extension.publications)
}
}
28 changes: 6 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,38 +1,22 @@
plugins {
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
}

group = "io.github.dogacel"
version = "0.0.01"

nexusPublishing {
this.repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
// ORG_GRADLE_PROJECT_sonatypeUsername
// ORG_GRADLE_PROJECT_sonatypePassword
username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
}
}
}

group = "io.github.dogacel"
version = "alpha-SNAPSHOT"

signing {
val signingKey = providers
.environmentVariable("GPG_SIGNING_KEY")
.forUseAtConfigurationTime()
val signingPassphrase = providers
.environmentVariable("GPG_SIGNING_PASSPHRASE")
.forUseAtConfigurationTime()
if (signingKey.isPresent && signingPassphrase.isPresent) {
useInMemoryPgpKeys(signingKey.get(), signingPassphrase.get())
val extension = extensions
.getByName("publishing") as PublishingExtension
sign(extension.publications)
}
}

subprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint") // Version should be inherited from parent

Expand Down
33 changes: 25 additions & 8 deletions runtime-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ plugins {
id("org.jetbrains.kotlin.jvm")
kotlin("plugin.serialization")
`java-library`
`maven-publish`
id("org.jetbrains.dokka")
id("org.jetbrains.kotlinx.kover")

// Publishing
`maven-publish`
signing
}

repositories {
Expand Down Expand Up @@ -78,6 +81,16 @@ tasks.jar {
// }
// }

ktlint {
filter {
exclude { entry ->
val condition =
entry.file.toString().contains(".proto.kt") || entry.file.toString().contains("generated")
condition
}
}
}

// Publishing

val sourcesJar by tasks.registering(Jar::class) {
Expand Down Expand Up @@ -133,12 +146,16 @@ publishing {
}
}

ktlint {
filter {
exclude { entry ->
val condition =
entry.file.toString().contains(".proto.kt") || entry.file.toString().contains("generated")
condition
}
signing {
val signingKey = providers.environmentVariable("GPG_SIGNING_KEY")
val signingPassphrase = providers.environmentVariable("GPG_SIGNING_PASSPHRASE")

if (signingKey.isPresent && signingPassphrase.isPresent) {
useInMemoryPgpKeys(
signingKey.get(),
signingPassphrase.get(),
)
val extension = extensions.getByName("publishing") as PublishingExtension
sign(extension.publications)
}
}

0 comments on commit 716d932

Please sign in to comment.