Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add publish gradle task and release workflows #12

Merged
merged 6 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/manual-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Manual Release
# Triggers a merge from main->release, which will then trigger a release
# from the release branch.
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
merge-to-release-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Merge main -> release
uses: devmasx/merge-branch@master
with:
type: now
from_branch: main
target_branch: release
github_token: ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }}
57 changes: 57 additions & 0 deletions .github/workflows/on-push-to-release-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: On push to release branch

on:
push:
branches: [release]

jobs:
release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.release.outputs.release }}
steps:
- uses: actions/checkout@v3
- name: Set release
id: semrel
uses: go-semantic-release/action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
allow-initial-development-versions: true
force-bump-patch-version: true
# For whatever reason, this silly tool won't let you do releases from branches
# other than the default branch unless you pass this flag, which doesn't seem
# to actually have anything to do with CI:
# https://github.com/go-semantic-release/semantic-release/blob/master/cmd/semantic-release/main.go#L173-L194
# https://github.com/go-semantic-release/condition-github/blob/4c8af3fc516151423fff2f77eb08bf7082570676/pkg/condition/github.go#L42-L44
custom-arguments: '--no-ci'

- name: Output release
id: release
run: echo "release=${{ steps.semrel.outputs.version }}" >> $GITHUB_OUTPUT

publish:
runs-on: ubuntu-latest

steps:
- name: Checkout project
uses: actions/checkout@v3

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

- name: Build project
run: make build

# - 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: ${{ needs.release.outputs.version }}
# uses: gradle/gradle-build-action@v2
# with:
# arguments: publishToSonatype closeAndReleaseStagingRepository
malandis marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ repositories {
mavenCentral()
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

dependencies {
implementation("io.lettuce:lettuce-core:6.4.0.RELEASE")
implementation("software.momento.java:sdk:1.15.0")
Expand All @@ -35,3 +40,5 @@ spotless {
googleJavaFormat("1.11.0")
}
}

apply(from="publish.gradle.kts")
76 changes: 76 additions & 0 deletions publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
plugins {
id("maven-publish")
id("signing")
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
}

group = "software.momento.java"
version = "0.1.0"

java {
withSourcesJar()
withJavadocJar()
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
groupId = group.toString()
artifactId = "momento-lettuce"
version = project.version.toString()

pom {
name.set("Momento Lettuce Compatibility Client")
description.set("Momento-backed implementation of the Lettuce Redis client")
url.set("https://github.com/momentohq/momento-java-lettuce-client")
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("momento")
name.set("Momento")
organization.set("Momento")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:git://github.com/momentohq/momento-java-lettuce-client.git")
developerConnection.set("scm:git:[email protected]:momentohq/momento-java-lettuce-client.git")
url.set("https://github.com/momentohq/momento-java-lettuce-client")
}
}
}
}
}

// Signing and Nexus publishing setup
val signingKey: String? = System.getenv("SONATYPE_SIGNING_KEY")
val signingPassword: String? = System.getenv("SONATYPE_SIGNING_KEY_PASSWORD")

if (signingKey != null && signingPassword != null) {
signing {
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["mavenJava"])
}
}

val sonatypeUsername: String? = System.getenv("SONATYPE_USERNAME")
val sonatypePassword: String? = System.getenv("SONATYPE_PASSWORD")

if (sonatypeUsername != null && sonatypePassword != null) {
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(sonatypeUsername)
password.set(sonatypePassword)
}
}
}
}
Loading