Skip to content

Commit

Permalink
Publish Java library with GitHub Action
Browse files Browse the repository at this point in the history
Adds GitHub Action to automate the deploying of the library to Maven on
changes to the master branch. Utilizes the `setup-java` action as well
as the `nexus-staging-maven-plugin`.
  • Loading branch information
brettmortensen committed Jan 10, 2022
1 parent 592c8a6 commit 55bd3ff
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 23 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish

on:
push:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'

- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Set up Apache Maven Central
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: MAVEN_GPG_PRIVATE_KEY
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Publish to Apache Maven Central
run: mvn deploy -P sign-artifacts
env:
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
MAVEN_GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mvn clean package
```

Then manually install the following JARs:
- `target/mx-platform-java-0.4.0.jar`
- `target/mx-platform-java-0.4.1.jar`
- `target/lib/*.jar`

### Maven users
Expand All @@ -35,7 +35,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>com.mx</groupId>
<artifactId>mx-platform-java</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -55,6 +55,7 @@ import com.mx.client.Configuration;
import com.mx.client.auth.*;
import com.mx.client.model.*;
import com.mx.client.mx_platform_api.MxPlatformApi;
import java.util.*;

public class Example {
public static void main(String[] args) {
Expand All @@ -69,10 +70,9 @@ public class Example {

MxPlatformApi apiInstance = new MxPlatformApi(defaultClient);

UserCreateRequestBody userCreateRequestBody = new UserCreateRequestBody();
UserCreateRequest userCreateRequest = new UserCreateRequest();
userCreateRequest.setMetadata("Creating a user!");

UserCreateRequestBody userCreateRequestBody = new UserCreateRequestBody();
userCreateRequestBody.setUser(userCreateRequest);

try {
Expand Down
2 changes: 1 addition & 1 deletion openapi/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiPackage: "com.mx.client.mx-platform-api"
artifactDescription: "A Java library for the MX Platform API"
artifactId: "mx-platform-java"
artifactUrl: "https://github.com/mxenabled/mx-platform-java"
artifactVersion: 0.4.0
artifactVersion: 0.4.1
developerEmail: "[email protected]"
developerName: "MX"
developerOrganization: "MX Technologies Inc."
Expand Down
4 changes: 2 additions & 2 deletions openapi/templates/README.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import com.mx.client.Configuration;
import com.mx.client.auth.*;
import com.mx.client.model.*;
import com.mx.client.mx_platform_api.MxPlatformApi;
import java.util.*;

public class Example {
public static void main(String[] args) {
Expand All @@ -69,10 +70,9 @@ public class Example {
MxPlatformApi apiInstance = new MxPlatformApi(defaultClient);
UserCreateRequestBody userCreateRequestBody = new UserCreateRequestBody();
UserCreateRequest userCreateRequest = new UserCreateRequest();
userCreateRequest.setMetadata("Creating a user!");
UserCreateRequestBody userCreateRequestBody = new UserCreateRequestBody();
userCreateRequestBody.setUser(userCreateRequest);
try {
Expand Down
19 changes: 12 additions & 7 deletions openapi/templates/pom.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
</configuration>
</plugin>
</plugins>
</build>

Expand All @@ -211,7 +222,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand All @@ -221,12 +232,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
</goals>
</execution>
</executions>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
21 changes: 13 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<artifactId>mx-platform-java</artifactId>
<packaging>jar</packaging>
<name>mx-platform-java</name>
<version>0.4.0</version>
<version>0.4.1</version>
<url>https://github.com/mxenabled/mx-platform-java</url>
<description>A Java library for the MX Platform API</description>
<scm>
Expand Down Expand Up @@ -182,6 +182,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
</configuration>
</plugin>
</plugins>
</build>

Expand All @@ -204,7 +215,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand All @@ -214,12 +225,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
</goals>
</execution>
</executions>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/mx/client/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void init() {
json = new JSON();

// Set default User-Agent.
setUserAgent("OpenAPI-Generator/0.4.0/java");
setUserAgent("OpenAPI-Generator/0.4.1/java");

authentications = new HashMap<String, Authentication>();
}
Expand Down

0 comments on commit 55bd3ff

Please sign in to comment.