Skip to content

Commit

Permalink
Merge pull request #39 from momentohq/release-please
Browse files Browse the repository at this point in the history
feat: add release job
  • Loading branch information
nand4011 authored Jan 8, 2024
2 parents b911e46 + 11eb916 commit 04b530a
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 3 deletions.
58 changes: 57 additions & 1 deletion .github/workflows/on-push-to-main-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [main]

jobs:
test:
generate-readme:
runs-on: ubuntu-latest
steps:
- name: Setup repo
Expand All @@ -21,3 +21,59 @@ jobs:
project_type: sdk
sdk_language: Kotlin
dev_docs_slug: kotlin

release-please:
runs-on: ubuntu-latest
needs: [ generate-readme ]
outputs:
release_created: ${{ steps.release.outputs.release_created }}
name: Release Please
steps:
- uses: google-github-actions/release-please-action@v4
id: release
with:
token: ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }}
path: src
release-type: java
package-name: client-sdk-kotlin
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]'
extra-files: |
build.gradle.kts
publish:
runs-on: ubuntu-latest
needs: [ release-please ]
if: needs.release-please.outputs.release_created == 'true'
steps:
- name: Setup repo
uses: actions/checkout@v4
with:
token: ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }}

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'corretto'

# The Android SDK is required to build the project, even if we are not running Android tests.
- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Build project
uses: gradle/[email protected]
with:
arguments: clean build -x jvmTest -x testDebugUnitTest -x testReleaseUnitTest

- name: Publish to sonatype
env:
SONATYPE_SIGNING_KEY: ${{ secrets.SONATYPE_SIGNING_KEY }}
SONATYPE_SIGNING_KEY_PASSWORD: ${{ secrets.SONATYPE_SIGNING_KEY_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_version: ${{ steps.semrel.outputs.version }}
uses: gradle/[email protected]
with:
# TODO: automatically release when release process is verified to work
# arguments: publishToSonatype closeAndReleaseStagingRepository
arguments: publishToSonatype closeSonatypeStagingRepository
21 changes: 19 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ plugins {
kotlin("plugin.serialization") version "1.9.21"
id("maven-publish")
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
signing
}

group = "software.momento.kotlin"
// x-release-please-start-version
version = "0.1.0-SNAPSHOT"
// x-release-please-end

repositories {
mavenCentral()
Expand Down Expand Up @@ -106,9 +109,14 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach
compilerOptions.languageVersion.set(KotlinVersion.KOTLIN_1_6)
}

val javadocJar = tasks.register("javadocJar", Jar::class.java) {
archiveClassifier.set("javadoc")
}

publishing {
publications {
named<MavenPublication>("kotlinMultiplatform") {
withType<MavenPublication> {
artifact(javadocJar)
pom {
name.set("Momento Kotlin SDK")
description.set("Kotlin client SDK for Momento Serverless Cache")
Expand Down Expand Up @@ -140,10 +148,19 @@ publishing {
nexusPublishing {
repositories {
sonatype {
// nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
}
}
}

// Sign only if we have a key to do so
val signingKey: String? = System.getenv("SONATYPE_SIGNING_KEY")
if (signingKey != null) {
signing {
useInMemoryPgpKeys(signingKey, System.getenv("SONATYPE_SIGNING_KEY_PASSWORD"))
sign(publishing.publications)
}
}

0 comments on commit 04b530a

Please sign in to comment.