From 512f7fc8cf50ff9bc4011098f586e9343f85913e Mon Sep 17 00:00:00 2001 From: Darwin <5746693+darwin67@users.noreply.github.com> Date: Thu, 29 Feb 2024 15:34:04 -0800 Subject: [PATCH] Publish spring-boot-adapter to Maven Central (#51) * 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 --- .github/workflows/ci.yml | 3 - .github/workflows/release.yml | 1 + README.md | 6 - inngest-spring-boot-adapter/VERSION | 1 + inngest-spring-boot-adapter/build.gradle.kts | 137 +++++++++++++++++-- inngest-spring-boot-adapter/maven-bundle | 19 +++ 6 files changed, 145 insertions(+), 22 deletions(-) create mode 100644 inngest-spring-boot-adapter/VERSION create mode 100755 inngest-spring-boot-adapter/maven-bundle diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef24e8ca..91a1506f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,9 +6,6 @@ on: - main pull_request: -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - jobs: test: name: Test (Java ${{ matrix.java }}) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50c28c34..b7ca43a4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: diff --git a/README.md b/README.md index 707e1ae6..2c6c58d1 100644 --- a/README.md +++ b/README.md @@ -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= GITHUB_TOKEN= -``` - To build this in development, set up Java, Kotlin and Gradle locally and run the test server: ``` diff --git a/inngest-spring-boot-adapter/VERSION b/inngest-spring-boot-adapter/VERSION new file mode 100644 index 00000000..4e379d2b --- /dev/null +++ b/inngest-spring-boot-adapter/VERSION @@ -0,0 +1 @@ +0.0.2 diff --git a/inngest-spring-boot-adapter/build.gradle.kts b/inngest-spring-boot-adapter/build.gradle.kts index e7b5a1cc..f05127f3 100644 --- a/inngest-spring-boot-adapter/build.gradle.kts +++ b/inngest-spring-boot-adapter/build.gradle.kts @@ -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 { @@ -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("gpr") { + register("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("eng@inngest.com") + } + } + + scm { + url.set("https://github.com/inngest/inngest-kt") + connection.set("scm:git:https://github.com/inngest/inngest-kt.git") + developerConnection.set("scm:git:git@github.com: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 { 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)", + ) + } + }), + ) + } } diff --git a/inngest-spring-boot-adapter/maven-bundle b/inngest-spring-boot-adapter/maven-bundle new file mode 100755 index 00000000..02fe575c --- /dev/null +++ b/inngest-spring-boot-adapter/maven-bundle @@ -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