Skip to content

Commit

Permalink
Publish spring-boot-adapter to Maven Central (#51)
Browse files Browse the repository at this point in the history
* copy gradle settings from inngest
* update publication name
* no longer require token for tests
* remove gh token requirement from README
* add adapter's VERSION file as part of filtering

---------

Co-authored-by: Darwin D Wu <[email protected]>
  • Loading branch information
darwin67 and darwin67 authored Feb 29, 2024
1 parent a98dfb9 commit 512f7fc
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 22 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
- main
pull_request:

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
test:
name: Test (Java ${{ matrix.java }})
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
with:
filters: |
inngest: inngest/VERSION
inngest-spring-boot-adapter: inngest-spring-boot-adapter/VERSION
# Publish will only run when it detects a change on top
publish:
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ WIP

## Contributing [WIP]

You'll need a GitHub token in order to be able to run the builds. Create a classic GitHub personal access token, and set it in your terminal.

```sh
export GITHUB_ACTOR=<your-username> GITHUB_TOKEN=<person-access-token>
```

To build this in development, set up Java, Kotlin and Gradle locally and run the test server:

```
Expand Down
1 change: 1 addition & 0 deletions inngest-spring-boot-adapter/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.2
137 changes: 124 additions & 13 deletions inngest-spring-boot-adapter/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

group = "com.inngest"
description = "Spring Boot adapter for Inngest SDK"
version = "0.0.1"
version = file("VERSION").readText().trim()

plugins {
`java-library`
id("java-library")
id("maven-publish")
id("signing")
id("io.spring.dependency-management") version "1.1.4"
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}

repositories {
mavenCentral()

maven {
url = uri("https://maven.pkg.github.com/inngest/inngest-kt")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
}

dependencies {
Expand All @@ -41,22 +39,135 @@ dependencyManagement {

publishing {
repositories {
// NOTE: Does not work: https://central.sonatype.org/publish/publish-portal-gradle/
// maven {
// name = "OSSRH"
// url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
// credentials {
// username = System.getenv("MAVEN_USERNAME")
// password = System.getenv("MAVEN_PASSWORD")
// }
// }

// NOTE: create a local repo and bundle this to upload it to Maven Central for now
maven {
// local repo
val releasesRepoUrl = uri(layout.buildDirectory.dir("repos/releases"))
val snapshotsRepoUrl = uri(layout.buildDirectory.dir("repos/snapshots"))
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
}

maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/inngest/inngest-kt")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
publications {
register<MavenPublication>("gpr") {
register<MavenPublication>("inngest-spring-boot-adapter") {
from(components["java"])

pom {
name.set(project.name)
description.set("Inngest SDK for Kotlin/Java")
url.set("https://github.com/inngest/inngest-kt")
inceptionYear.set("2024")

licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}

developers {
developer {
id.set("eng")
name.set("Inngest Engineering")
email.set("[email protected]")
}
}

scm {
url.set("https://github.com/inngest/inngest-kt")
connection.set("scm:git:https://github.com/inngest/inngest-kt.git")
developerConnection.set("scm:git:[email protected]:inngest/inngest-kt.git")
}
}
}
}
}

signing {
val signingKey = System.getenv("GPG_SIGNING_KEY")
val signingPasswd = System.getenv("GPG_SIGNING_KEY_PASSWORD")
useInMemoryPgpKeys(signingKey, signingPasswd)
sign(publishing.publications)
}

tasks.jar {
manifest {
attributes(
mapOf(
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
),
)
}
}

tasks.javadoc {
if (JavaVersion.current().isJava9Compatible) {
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
}
}

tasks.withType<Test> {
useJUnitPlatform()

testLogging {
events =
setOf(
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
)

exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
showExceptions = true
showCauses = true
showStackTraces = true

// set options for log level DEBUG and INFO
debug {
events =
setOf(
TestLogEvent.STARTED,
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT,
)

exceptionFormat = TestExceptionFormat.FULL
}

info.events = debug.events
info.exceptionFormat = debug.exceptionFormat

afterSuite(
KotlinClosure2({ desc: TestDescriptor, result: TestResult ->
if (desc.parent == null) { // will match the outermost suite
println(
"Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)",
)
}
}),
)
}
}
19 changes: 19 additions & 0 deletions inngest-spring-boot-adapter/maven-bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -e

RELEASES=build/repos/releases/com
ASSEMBLE=$(mktemp -d)
cp -R $RELEASES $ASSEMBLE

# Enter temp dir
pushd $ASSEMBLE

rm com/inngest/inngest-spring-boot-adapter/maven-*
zip -r bundle.zip com

popd

cp $ASSEMBLE/bundle.zip .

rm -rf $ASSEMBLE

0 comments on commit 512f7fc

Please sign in to comment.