-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup workflow to upload to Maven central (#49)
Update the SDK core's `build.gradle.kts` to publish to a local Maven repo (which is just basically a file path), and bundle that to send it over to Maven Central's publisher API. The new Maven Central don't have integration with gradle atm, so unfortunately, we'll just have to automate it in a way simulating a manual upload. https://central.sonatype.org/publish/publish-portal-api/ The `Release` github workflow is set to trigger when there are changes made to each project's `VERSION` file. Which assumes that we'll want to publish a new version. --------- Co-authored-by: Darwin D Wu <[email protected]>
- Loading branch information
Showing
6 changed files
with
135 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: | ||
- created | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
changes: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
pkgs: ${{ steps.filter.outputs.changes }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dorny/paths-filter@v3 | ||
id: filter | ||
with: | ||
filters: | | ||
inngest: inngest/VERSION | ||
# Publish will only run when it detects a change on top | ||
publish: | ||
needs: changes | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
pkg: ${{ fromJSON(needs.changes.outputs.pkgs) }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Java | ||
|
@@ -19,9 +36,40 @@ jobs: | |
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
|
||
- name: Set version | ||
working-directory: ${{ matrix.pkg }} | ||
run: echo "PKG_VERSION=$(cat VERSION)" >> $GITHUB_ENV | ||
|
||
- name: Publish package | ||
run: gradle publish | ||
working-directory: ${{ matrix.pkg }} | ||
run: gradle publish --info | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} | ||
GPG_SIGNING_KEY_PASSWORD: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }} | ||
|
||
- name: Create bundle for Maven Central | ||
working-directory: ${{ matrix.pkg }} | ||
run: ./maven-bundle | ||
|
||
- name: Upload bundle to Maven Central | ||
working-directory: ${{ matrix.pkg }} | ||
run: | | ||
# Generate bearer token | ||
TOKEN=$(echo -n $AUTH | base64) | ||
# Upload via API | ||
curl -v -X POST "$PUBLISHER_API?name=$PKG_NAME&publishingType=AUTOMATIC" \ | ||
-H "Authorization: Bearer $TOKEN" \ | ||
-F '[email protected]' | ||
env: | ||
AUTH: "${{ secrets.MAVEN_USERNAME }}:${{ secrets.MAVEN_PASSWORD }}" | ||
PKG_NAME: com.inngest:${{ matrix.pkg }}:${{ env.PKG_VERSION }} | ||
PUBLISHER_API: https://central.sonatype.com/api/v1/publisher/upload | ||
|
||
- name: Create tag for pkg | ||
run: git tag $TAG && git push $TAG | ||
env: | ||
TAG: ${{ matrix.pkg }}-${{ env.PKG_VERSION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,8 @@ gradle-app.setting | |
/.direnv | ||
.DS_Store | ||
.factorypath | ||
bundle.zip | ||
**/tmp/ | ||
|
||
# LSP generated | ||
**/.settings/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,20 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent | |
|
||
group = "com.inngest" | ||
description = "Inngest SDK" | ||
version = "0.0.2" | ||
version = file("VERSION").readText().trim() | ||
|
||
plugins { | ||
id("java-library") | ||
id("maven-publish") | ||
id("signing") | ||
id("org.jetbrains.kotlin.jvm") version "1.9.10" | ||
} | ||
|
||
// TODO - Move this to share conventions gradle file | ||
java { | ||
toolchain { languageVersion.set(JavaLanguageVersion.of(8)) } | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
repositories { | ||
|
@@ -34,31 +38,75 @@ dependencies { | |
|
||
publishing { | ||
repositories { | ||
// NOTE: Does not work: https://central.sonatype.org/publish/publish-portal-gradle/ | ||
// maven { | ||
// name = "OSSRH" | ||
// url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") | ||
// 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") { | ||
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( | ||
|
@@ -70,6 +118,12 @@ tasks.jar { | |
} | ||
} | ||
|
||
tasks.javadoc { | ||
if (JavaVersion.current().isJava9Compatible) { | ||
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true) | ||
} | ||
} | ||
|
||
tasks.named<Test>("test") { | ||
// Use JUnit Platform for unit tests. | ||
useJUnitPlatform() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/maven-* | ||
zip -r bundle.zip com | ||
|
||
popd | ||
|
||
cp $ASSEMBLE/bundle.zip . | ||
|
||
rm -rf $ASSEMBLE |