Skip to content

Commit

Permalink
chore(java-sdk): automate releases (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh authored Oct 13, 2023
2 parents da463f2 + 02d1c05 commit e350045
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 12 deletions.
6 changes: 6 additions & 0 deletions config/clients/java/CHANGELOG.md.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v0.2.1

### [0.2.1](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/compare/v0.2.0...v0.2.1) (2023-10-13)

No changes, this patch release is just to test release automation.

## v0.2.0

### [0.2.0](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/compare/v0.1.0...v0.2.0) (2023-10-11)
Expand Down
2 changes: 1 addition & 1 deletion config/clients/java/config.overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"gitRepoId": "java-sdk",
"artifactId": "openfga-sdk",
"groupId": "dev.openfga",
"packageVersion": "0.2.0",
"packageVersion": "0.2.1",
"apiPackage": "dev.openfga.sdk.api",
"authPackage": "dev.openfga.sdk.api.auth",
"clientPackage": "dev.openfga.sdk.api.client",
Expand Down
36 changes: 33 additions & 3 deletions config/clients/java/template/.github/workflows/main.yml.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: |
./gradlew build

publish:
publish-maven-central:
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -51,18 +51,48 @@ jobs:
- name: Publish package
uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # v2.8.0
with:
arguments: publish
# Tasks created by https://github.com/gradle-nexus/publish-plugin
arguments: publishpublishToSonatype closeAndReleaseSonatypeStagingRepository
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
ORG_GRADLE_PROJECT_SIGNINGKEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}
ORG_GRADLE_PROJECT_SIGNINGPASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}

publish-github-packages:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: startsWith(github.ref, 'refs/tags/v')
needs: [test]

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.2

- name: Set up JDK
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3.12.0
with:
java-version: 11
distribution: 'temurin'

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # v1.1.0

- name: Publish package
uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # v2.8.0
with:
# Tasks created by https://docs.gradle.org/current/userguide/publishing_maven.html
arguments: publishAllPublicationsToGitHubPackagesRepository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_SIGNINGKEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}
ORG_GRADLE_PROJECT_SIGNINGPASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}

create-release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: publish
needs: [publish-maven-central, publish-github-packages]

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions config/clients/java/template/build.gradle.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ plugins {
// Publishing
id 'maven-publish'
id 'signing'
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
}

apply from: 'publish.gradle'
Expand Down
19 changes: 11 additions & 8 deletions config/clients/java/template/publish.gradle.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ publishing {
}
}
repositories {
maven {
name = 'SonatypeOSSRH' // AKA: "Maven Central"
url = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
credentials {
username = System.getenv('MAVEN_USERNAME')
password = System.getenv('MAVEN_PASSWORD')
}
}
maven {
name = 'GitHubPackages'
url = 'https://maven.pkg.github.com/{{gitUserId}}/{{gitRepoId}}'
Expand All @@ -55,3 +47,14 @@ signing {
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.maven
}

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(System.getenv('MAVEN_USERNAME'))
password.set(System.getenv('MAVEN_PASSWORD'))
}
}
}

0 comments on commit e350045

Please sign in to comment.