Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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_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 jreleaserDeploy
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.6.0'
```

### Maven users
Expand All @@ -26,7 +26,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>com.authsignal</groupId>
<artifactId>authsignal-java</artifactId>
<version>2.3.0</version>
<version>2.6.0</version>
</dependency>
```

Expand Down
78 changes: 41 additions & 37 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -11,25 +11,9 @@ repositories {

dependencies {
implementation 'com.google.code.gson:gson:2.10.1'

testImplementation 'junit:junit:4.13.2'
}

def Properties properties = new Properties()
properties.load(project.rootProject.file("local.properties").newDataInputStream())

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")))
}
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -40,19 +24,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.'
Expand All @@ -77,16 +55,42 @@ publishing {
}
}
}
}

signing {
useInMemoryPgpKeys(
properties.getProperty("signing.keyId"),
properties.getProperty("signing.key"),
properties.getProperty("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 = System.getenv('SIGNING_PUBLIC_KEY')
secretKey = System.getenv('SIGNING_SECRET_KEY')
passphrase = System.getenv('SIGNING_PASSPHRASE')
}
deploy {
maven {
mavenCentral {
sonatype {
active = 'ALWAYS'
url = 'https://central.sonatype.com/api/v1/publisher'
username = System.getenv('MAVENCENTRAL_USERNAME')
password = System.getenv('MAVENCENTRAL_PASSWORD')
stagingRepository('build/staging-deploy')
}
}
}
}
}

test {
Expand Down
7 changes: 1 addition & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
pomName=Authsignal Server SDK for Java
pomArtifactId=authsignal-java
pomGroup=com.authsignal
pomPackaging=jar
versionName=2.5.0
versionCode=2025
version=2.6.0
2 changes: 1 addition & 1 deletion src/main/java/com/authsignal/AuthsignalClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
26 changes: 19 additions & 7 deletions src/test/java/com/authsignal/AuthsignalClientTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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("test.baseURL");

String secret = localProperties.getProperty("test.secret");
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);
Expand Down
24 changes: 18 additions & 6 deletions src/test/java/com/authsignal/WebhookTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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("test.secret");
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
Expand Down
Loading