From 66f01aac0bdcd1c10cbfee4d25365f0db60b42d4 Mon Sep 17 00:00:00 2001 From: Chris Fisher Date: Tue, 15 Jul 2025 16:39:43 +1200 Subject: [PATCH 1/8] Add publish action --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++++++++++++++ .github/workflows/publish.yml | 34 ++++++++++++++++++++++++++++++++++ README.md | 4 ++-- 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..64c8452 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: Build Authsignal Java SDK + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: "17" + distribution: "temurin" + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + env: + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + run: ./gradlew build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..fd8a213 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,34 @@ +name: Publish Authsignal Java SDK + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: "17" + distribution: "temurin" + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build and Publish + env: + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + run: | + ./gradlew build + ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository diff --git a/README.md b/README.md index 82932fd..f007283 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Check out our [official Java SDK documentation](https://docs.authsignal.com/sdks Add this dependency to your project's build file: ```groovy -implementation 'com.authsignal:authsignal-java:2.3.0' +implementation 'com.authsignal:authsignal-java:2.5.0' ``` ### Maven users @@ -26,7 +26,7 @@ Add this dependency to your project's POM: com.authsignal authsignal-java - 2.3.0 + 2.5.0 ``` From 3407a08aa849690696aac1713abf24449499dbb1 Mon Sep 17 00:00:00 2001 From: Chris Fisher Date: Wed, 16 Jul 2025 11:28:26 +1200 Subject: [PATCH 2/8] wip --- .github/workflows/ci.yml | 34 ------------------- build.gradle | 20 ++++++----- .../com/authsignal/AuthsignalClientTests.java | 4 +-- .../java/com/authsignal/WebhookTests.java | 2 +- 4 files changed, 15 insertions(+), 45 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 64c8452..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Build Authsignal Java SDK - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: "17" - distribution: "temurin" - cache: gradle - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Build with Gradle - env: - SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - run: ./gradlew build diff --git a/build.gradle b/build.gradle index befaf29..ea0a8cb 100644 --- a/build.gradle +++ b/build.gradle @@ -18,14 +18,18 @@ dependencies { def Properties properties = new Properties() properties.load(project.rootProject.file("local.properties").newDataInputStream()) +def getProp = { propKey -> + System.getenv(propKey) ?: properties.getProperty(propKey) +} + nexusPublishing { repositories { sonatype { - username.set(properties.getProperty("ossrhUsername")) - password.set(properties.getProperty("ossrhPassword")) - stagingProfileId.set(properties.getProperty("sonatypeStagingProfileId")) - nexusUrl.set(uri(properties.getProperty("nexusUrl"))) - snapshotRepositoryUrl.set(uri(properties.getProperty("snapshotRepositoryUrl"))) + username.set(getProp("ossrhUsername")) + password.set(getProp("ossrhPassword")) + stagingProfileId.set(getProp("sonatypeStagingProfileId")) + nexusUrl.set(uri( getProp("nexusUrl"))) + snapshotRepositoryUrl.set(uri(getProp("snapshotRepositoryUrl"))) } } } @@ -81,9 +85,9 @@ publishing { signing { useInMemoryPgpKeys( - properties.getProperty("signing.keyId"), - properties.getProperty("signing.key"), - properties.getProperty("signing.password"), + getProp("signingKeyId"), + getProp("signingKey"), + getProp("signingPassword"), ) sign publishing.publications.mavenJava diff --git a/src/test/java/com/authsignal/AuthsignalClientTests.java b/src/test/java/com/authsignal/AuthsignalClientTests.java index c3e6780..654e71d 100644 --- a/src/test/java/com/authsignal/AuthsignalClientTests.java +++ b/src/test/java/com/authsignal/AuthsignalClientTests.java @@ -22,9 +22,9 @@ public AuthsignalClientTests() throws FileNotFoundException, IOException { Properties localProperties = new Properties(); localProperties.load(new FileInputStream(System.getProperty("user.dir") + "/local.properties")); - baseURL = localProperties.getProperty("test.baseURL"); + baseURL = localProperties.getProperty("testBaseURL"); - String secret = localProperties.getProperty("test.secret"); + String secret = localProperties.getProperty("testSecret"); client = new AuthsignalClient(secret, baseURL); } diff --git a/src/test/java/com/authsignal/WebhookTests.java b/src/test/java/com/authsignal/WebhookTests.java index 05fa905..f0a0279 100644 --- a/src/test/java/com/authsignal/WebhookTests.java +++ b/src/test/java/com/authsignal/WebhookTests.java @@ -18,7 +18,7 @@ public WebhookTests() throws FileNotFoundException, IOException { Properties localProperties = new Properties(); localProperties.load(new FileInputStream(System.getProperty("user.dir") + "/local.properties")); - String apiSecretKey = localProperties.getProperty("test.secret"); + String apiSecretKey = localProperties.getProperty("testSecret"); webhook = new Webhook(apiSecretKey); } From 9e2b4c55624fe8112f54fad4bf96b97f8e7df634 Mon Sep 17 00:00:00 2001 From: Chris Fisher Date: Wed, 16 Jul 2025 11:41:16 +1200 Subject: [PATCH 3/8] wip --- build.gradle | 16 ++++++------ .../com/authsignal/AuthsignalClientTests.java | 26 ++++++++++++++----- .../java/com/authsignal/WebhookTests.java | 24 ++++++++++++----- 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/build.gradle b/build.gradle index ea0a8cb..5e0dacf 100644 --- a/build.gradle +++ b/build.gradle @@ -25,11 +25,11 @@ def getProp = { propKey -> nexusPublishing { repositories { sonatype { - username.set(getProp("ossrhUsername")) - password.set(getProp("ossrhPassword")) - stagingProfileId.set(getProp("sonatypeStagingProfileId")) - nexusUrl.set(uri( getProp("nexusUrl"))) - snapshotRepositoryUrl.set(uri(getProp("snapshotRepositoryUrl"))) + username.set(getProp("OSSRH_USERNAME")) + password.set(getProp("OSSRH_PASSWORD")) + stagingProfileId.set(getProp("SONATYPE_STAGING_PROFILE_ID")) + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) } } } @@ -85,9 +85,9 @@ publishing { signing { useInMemoryPgpKeys( - getProp("signingKeyId"), - getProp("signingKey"), - getProp("signingPassword"), + getProp("SIGNING_KEY_ID"), + getProp("SIGNING_KEY"), + getProp("SIGNING_PASSWORD"), ) sign publishing.publications.mavenJava diff --git a/src/test/java/com/authsignal/AuthsignalClientTests.java b/src/test/java/com/authsignal/AuthsignalClientTests.java index 654e71d..6cb2dfb 100644 --- a/src/test/java/com/authsignal/AuthsignalClientTests.java +++ b/src/test/java/com/authsignal/AuthsignalClientTests.java @@ -7,7 +7,6 @@ import com.authsignal.model.*; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.concurrent.ExecutionException; import java.util.HashMap; @@ -18,17 +17,30 @@ public class AuthsignalClientTests { private final String baseURL; private AuthsignalClient client; - public AuthsignalClientTests() throws FileNotFoundException, IOException { - Properties localProperties = new Properties(); - localProperties.load(new FileInputStream(System.getProperty("user.dir") + "/local.properties")); + public AuthsignalClientTests() { + baseURL = getProp("AUTHSIGNAL_URL"); - baseURL = localProperties.getProperty("testBaseURL"); - - String secret = localProperties.getProperty("testSecret"); + String secret = getProp("AUTHSIGNAL_SECRET"); client = new AuthsignalClient(secret, baseURL); } + private String getProp(String name) { + String value = System.getenv(name); + + if (value == null) { + try { + Properties localProperties = new Properties(); + localProperties.load(new FileInputStream(System.getProperty("user.dir") + "/local.properties")); + value = localProperties.getProperty(name); + } catch (IOException e) { + throw new RuntimeException("Failed to load properties file", e); + } + } + + return value; + } + @Test public void testInvalidApiSecretKey() { AuthsignalClient invalidClient = new AuthsignalClient("invalid_secret", baseURL); diff --git a/src/test/java/com/authsignal/WebhookTests.java b/src/test/java/com/authsignal/WebhookTests.java index f0a0279..b83c050 100644 --- a/src/test/java/com/authsignal/WebhookTests.java +++ b/src/test/java/com/authsignal/WebhookTests.java @@ -7,20 +7,32 @@ import com.authsignal.model.WebhookEvent; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.Properties; public class WebhookTests { private Webhook webhook; - public WebhookTests() throws FileNotFoundException, IOException { - Properties localProperties = new Properties(); - localProperties.load(new FileInputStream(System.getProperty("user.dir") + "/local.properties")); + public WebhookTests() { + String secret = getProp("AUTHSIGNAL_SECRET"); - String apiSecretKey = localProperties.getProperty("testSecret"); + webhook = new Webhook(secret); + } + + private String getProp(String name) { + String value = System.getenv(name); + + if (value == null) { + try { + Properties localProperties = new Properties(); + localProperties.load(new FileInputStream(System.getProperty("user.dir") + "/local.properties")); + value = localProperties.getProperty(name); + } catch (IOException e) { + throw new RuntimeException("Failed to load properties file", e); + } + } - webhook = new Webhook(apiSecretKey); + return value; } @Test From 0bbae037ebbf33d782088f972b51c89f791e37e6 Mon Sep 17 00:00:00 2001 From: Chris Fisher Date: Wed, 16 Jul 2025 16:47:41 +1200 Subject: [PATCH 4/8] Use JReleaser --- .gitignore | 2 + README.md | 4 +- build.gradle | 75 ++++++++++--------- gradle.properties | 7 +- .../java/com/authsignal/AuthsignalClient.java | 2 +- 5 files changed, 47 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index f9c0a61..d5d4b10 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .gradle build local.properties +pgp-private-key +pgp-public-key .vscode \ No newline at end of file diff --git a/README.md b/README.md index f007283..ce0c1ac 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Check out our [official Java SDK documentation](https://docs.authsignal.com/sdks Add this dependency to your project's build file: ```groovy -implementation 'com.authsignal:authsignal-java:2.5.0' +implementation 'com.authsignal:authsignal-java:2.6.0' ``` ### Maven users @@ -26,7 +26,7 @@ Add this dependency to your project's POM: com.authsignal authsignal-java - 2.5.0 + 2.6.0 ``` diff --git a/build.gradle b/build.gradle index 5e0dacf..77653d3 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id 'java-library' id 'maven-publish' id 'signing' - id 'io.github.gradle-nexus.publish-plugin' version '1.3.0' + id 'org.jreleaser' version '1.19.0' } repositories { @@ -11,7 +11,6 @@ repositories { dependencies { implementation 'com.google.code.gson:gson:2.10.1' - testImplementation 'junit:junit:4.13.2' } @@ -22,18 +21,6 @@ def getProp = { propKey -> System.getenv(propKey) ?: properties.getProperty(propKey) } -nexusPublishing { - repositories { - sonatype { - username.set(getProp("OSSRH_USERNAME")) - password.set(getProp("OSSRH_PASSWORD")) - stagingProfileId.set(getProp("SONATYPE_STAGING_PROFILE_ID")) - nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) - } - } -} - java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 @@ -44,19 +31,13 @@ java { publishing { publications { - mavenJava(MavenPublication) { - artifactId = project.pomArtifactId - groupId = project.pomGroup - version = project.versionName + maven(MavenPublication) { + groupId = 'com.authsignal' + artifactId = 'authsignal-java' + version = project.version + from components.java - versionMapping { - usage('java-api') { - fromResolutionOf('runtimeClasspath') - } - usage('java-runtime') { - fromResolutionResult() - } - } + pom { name = 'authsignal-java' description = 'The Authsignal Server SDK for Java.' @@ -81,16 +62,42 @@ publishing { } } } -} -signing { - useInMemoryPgpKeys( - getProp("SIGNING_KEY_ID"), - getProp("SIGNING_KEY"), - getProp("SIGNING_PASSWORD"), - ) + repositories { + maven { + url = layout.buildDirectory.dir('staging-deploy') + } + } +} - sign publishing.publications.mavenJava +jreleaser { + project { + java { + groupId = 'com.authsignal' + artifactId = 'authsignal-java' + description = 'The Authsignal Server SDK for Java.' + version = project.version + } + } + signing { + active = 'ALWAYS' + publicKey = file('pgp-public-key').text + secretKey = file('pgp-private-key').text + passphrase = getProp('PGP_PASSPHRASE') + } + deploy { + maven { + mavenCentral { + sonatype { + active = 'ALWAYS' + url = 'https://central.sonatype.com/api/v1/publisher' + username = getProp('MAVENCENTRAL_USERNAME') + password = getProp('MAVENCENTRAL_PASSWORD') + stagingRepository('build/staging-deploy') + } + } + } + } } test { diff --git a/gradle.properties b/gradle.properties index 7aa77fd..64dd7a6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1 @@ -pomName=Authsignal Server SDK for Java -pomArtifactId=authsignal-java -pomGroup=com.authsignal -pomPackaging=jar -versionName=2.5.0 -versionCode=2025 \ No newline at end of file +version=2.6.0 \ No newline at end of file diff --git a/src/main/java/com/authsignal/AuthsignalClient.java b/src/main/java/com/authsignal/AuthsignalClient.java index 4820cf4..684bd07 100644 --- a/src/main/java/com/authsignal/AuthsignalClient.java +++ b/src/main/java/com/authsignal/AuthsignalClient.java @@ -27,7 +27,7 @@ public class AuthsignalClient { private static final String DEFAULT_API_URL = "https://api.authsignal.com/v1"; private static final int DEFAULT_RETRIES = 2; - private static final String VERSION = "2.5.0"; + private static final String VERSION = "2.6.0"; public Webhook webhook; From 02ebcf721ba4c469c6ab172cecc08dfc50f2fe94 Mon Sep 17 00:00:00 2001 From: Chris Fisher Date: Wed, 16 Jul 2025 16:49:40 +1200 Subject: [PATCH 5/8] wip --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 77653d3..2fe9a7e 100644 --- a/build.gradle +++ b/build.gradle @@ -83,7 +83,7 @@ jreleaser { active = 'ALWAYS' publicKey = file('pgp-public-key').text secretKey = file('pgp-private-key').text - passphrase = getProp('PGP_PASSPHRASE') + passphrase = getProp('SIGNING_PASSPHRASE') } deploy { maven { From a6daec4fccd46fbb47df167c27434e5c11510610 Mon Sep 17 00:00:00 2001 From: Chris Fisher Date: Wed, 16 Jul 2025 16:51:28 +1200 Subject: [PATCH 6/8] wip --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 2fe9a7e..a0ee7c9 100644 --- a/build.gradle +++ b/build.gradle @@ -81,8 +81,8 @@ jreleaser { } signing { active = 'ALWAYS' - publicKey = file('pgp-public-key').text - secretKey = file('pgp-private-key').text + publicKey = System.getenv('SIGNING_PUBLIC_KEY') ?: file('pgp-public-key').text + secretKey = System.getenv('SIGNING_SECRET_KEY') ?: file('pgp-private-key').text passphrase = getProp('SIGNING_PASSPHRASE') } deploy { From e71d29798ecbd096b12819cf9667b31700653cb1 Mon Sep 17 00:00:00 2001 From: Chris Fisher Date: Wed, 16 Jul 2025 16:54:58 +1200 Subject: [PATCH 7/8] wip --- .gitignore | 2 -- build.gradle | 17 +++++------------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index d5d4b10..f9c0a61 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ .gradle build local.properties -pgp-private-key -pgp-public-key .vscode \ No newline at end of file diff --git a/build.gradle b/build.gradle index a0ee7c9..ca0c091 100644 --- a/build.gradle +++ b/build.gradle @@ -14,13 +14,6 @@ dependencies { testImplementation 'junit:junit:4.13.2' } -def Properties properties = new Properties() -properties.load(project.rootProject.file("local.properties").newDataInputStream()) - -def getProp = { propKey -> - System.getenv(propKey) ?: properties.getProperty(propKey) -} - java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 @@ -81,9 +74,9 @@ jreleaser { } signing { active = 'ALWAYS' - publicKey = System.getenv('SIGNING_PUBLIC_KEY') ?: file('pgp-public-key').text - secretKey = System.getenv('SIGNING_SECRET_KEY') ?: file('pgp-private-key').text - passphrase = getProp('SIGNING_PASSPHRASE') + publicKey = System.getenv('SIGNING_PUBLIC_KEY') + secretKey = System.getenv('SIGNING_SECRET_KEY') + passphrase = System.getenv('SIGNING_PASSPHRASE') } deploy { maven { @@ -91,8 +84,8 @@ jreleaser { sonatype { active = 'ALWAYS' url = 'https://central.sonatype.com/api/v1/publisher' - username = getProp('MAVENCENTRAL_USERNAME') - password = getProp('MAVENCENTRAL_PASSWORD') + username = System.getenv('MAVENCENTRAL_USERNAME') + password = System.getenv('MAVENCENTRAL_PASSWORD') stagingRepository('build/staging-deploy') } } From c392d609cc7a722c90304884a1d3fb1cbbfc9752 Mon Sep 17 00:00:00 2001 From: Chris Fisher Date: Wed, 16 Jul 2025 16:57:48 +1200 Subject: [PATCH 8/8] wip --- .github/workflows/publish.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fd8a213..91068a8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,12 +23,12 @@ jobs: - name: Build and Publish env: - SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + SIGNING_PUBLIC_KEY: ${{ secrets.SIGNING_PUBLIC_KEY }} + SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }} + SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} + MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }} + MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }} run: | + ./gradlew clean ./gradlew build - ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository + ./gradlew jreleaserDeploy