Skip to content

Commit

Permalink
Deploy to maven central (#303)
Browse files Browse the repository at this point in the history
* deploy to maven central
* bump version

---------

Co-authored-by: orhoj <[email protected]>
Co-authored-by: Shjorty <[email protected]>
  • Loading branch information
3 people authored Feb 2, 2024
1 parent 7df3be5 commit 7488808
Show file tree
Hide file tree
Showing 8 changed files with 302 additions and 77 deletions.
103 changes: 64 additions & 39 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ env:
jobs:
build-native-ubuntu:
runs-on: ubuntu-22.04

steps:
# Setup rust
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.69

# Checkout the code
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive

- name: Make ubuntu native dependencies
run: make

Expand All @@ -39,23 +39,23 @@ jobs:

build-native-macos:
runs-on: macos-latest

steps:
# Setup rust
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.69

# Checkout the code
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive

- name: Make macos native dependencies
run: make

- name: Upload macos library
uses: actions/upload-artifact@master
with:
Expand All @@ -64,30 +64,30 @@ jobs:

build-native-windows:
runs-on: windows-latest

steps:
# Setup rust
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.69

# Checkout the code
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive

- name: Make windows native dependencies
run: cd crypto-jni && cargo build --release

- name: Upload windows library
uses: actions/upload-artifact@master
with:
name: windows-library
path: crypto-jni\target\release\crypto_jni.dll

build-aar-library:
build-native-android:
runs-on: ubuntu-22.04
steps:
- name: Set Up Android tools
Expand All @@ -107,44 +107,42 @@ jobs:
submodules: recursive
- name: Make android native dependencies
run: make add-android-targets && make android
# Builds and tests the sdk
- name: Initialize root project
run: mvn install -N
- name: Build and test android sdk
run: cd concordium-android-sdk && mvn --batch-mode --update-snapshots install
- name: Upload aar
- name: Upload android
uses: actions/upload-artifact@master
with:
name: concordium-android-sdk.aar
path: ./concordium-android-sdk/target/concordium-android-sdk.aar
name: android-library
path: ./concordium-android-sdk/native

build-and-release-jar:
needs: [build-native-ubuntu, build-native-macos, build-native-windows, build-aar-library]
needs: [build-native-ubuntu, build-native-macos, build-native-windows, build-native-android]
# Use fixed OS version because we install packages on the system.
runs-on: ubuntu-22.04
environment: release

if: ${{ !github.event.pull_request.draft }}

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive

- name: Set Up Android tools
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager \
--sdk_root=$ANDROID_SDK_ROOT \
"platform-tools" "platforms;android-27" "build-tools;27.0.3"
- name: Setup JDK 8
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 8
distribution: 'adopt'
cache: maven

- name: Download linux library
uses: actions/download-artifact@master
with:
name: ubuntu-library
path: concordium-sdk/native

- name: Download macos library
uses: actions/download-artifact@master
with:
Expand All @@ -157,23 +155,15 @@ jobs:
name: windows-library
path: concordium-sdk/native

- name: Download aar library
- name: Download android library
uses: actions/download-artifact@master
with:
name: concordium-android-sdk.aar
path: concordium-android-sdk/target
name: android-library
path: ./concordium-android-sdk/native

# Builds and tests the sdk. Delomboks code and generates a javadoc jar from the delombok'ed code
- name: Build and test sdk
run: cd concordium-sdk && mvn --batch-mode --update-snapshots install && mvn lombok:delombok -f pom.xml && mvn javadoc:jar -f pom.xml

# Attach jar files to release (jar, jar-with-dependencies and javadoc-jar)
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
concordium-sdk/target/*.jar
concordium-android-sdk/target/concordium-android-sdk.aar
run: cd concordium-sdk && mvn --batch-mode --update-snapshots install -Pwith-dependencies && mvn lombok:delombok -f pom.xml && mvn javadoc:jar -f pom.xml && mvn source:jar

- name: Deploy javadoc
uses: MathieuSoysal/[email protected]
Expand All @@ -186,4 +176,39 @@ jobs:
without-checkout: true
project: maven
custom-command: cd concordium-sdk && mvn javadoc:javadoc -f pom.xml # Generates javadoc from the delombok'ed code

- name: Release github
uses: softprops/action-gh-release@v1
with:
files: |
concordium-sdk/target/*-with-dependencies.jar
concordium-sdk/target/*-javadoc.jar
concordium-sdk/target/*-sources.jar
- name: Setup and maven central
uses: actions/setup-java@v4
with: # running setup-java again overwrites the settings.xml
distribution: 'adopt'
java-version: '8'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_PASSWORD # env variable for token in deploy
gpg-private-key: ${{ secrets.SONATYPE_PKEY }} # Value of the GPG private key to import
gpg-passphrase: GPG_PASSPHRASE # Passphrase for the GPG private key
- name: Publish java package to central maven repository
run: cd concordium-sdk && mvn --batch-mode deploy -Pdeploy
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USR }}
MAVEN_PASSWORD: ${{ secrets.SONATYPE_PWD }}
GPG_PASSPHRASE: ${{secrets.SONATYPE_PHRASE }}
- name: Copy javadocs and sources for android
run: >
mkdir -p concordium-android-sdk/target
&& mv concordium-sdk/target/*-javadoc.jar concordium-android-sdk/target/concordium-android-sdk-javadoc.jar
&& mv concordium-sdk/target/*-sources.jar concordium-android-sdk/target/concordium-android-sdk-sources.jar
- name: Publish android package to central maven repository
run: cd concordium-android-sdk && mvn --batch-mode deploy -Pdeploy
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USR }}
MAVEN_PASSWORD: ${{ secrets.SONATYPE_PWD }}
GPG_PASSPHRASE: ${{secrets.SONATYPE_PHRASE }}


4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.vscode
*.iml
*.iml
.flattened-pom.xml
pom.xml.versionsBackup
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Concordium Java SDK
The Concordium Java SDK provides an interface to communicating with a Concordium node.

The package is released on [Maven Central](https://central.sonatype.com/artifact/com.concordium.sdk/concordium-sdk).
The Android compatible package is also released on [Maven Central](https://central.sonatype.com/artifact/com.concordium.sdk/concordium-android-sdk).

# Prerequisites
1. Java 1.8
Expand Down Expand Up @@ -86,20 +88,6 @@ git clone https://github.com/Concordium/concordium-java-sdk.git --recurse-submod
And the final step builds the aar file `concordium-android-sdk.aar` in the [target](./concordium-android-sdk/target) folder, which can be used in android projects.
Note that this uses the [Android Maven Plugin](http://simpligility.github.io/android-maven-plugin/), which is what requires the Android SDK, the specific version can be seen in its documentation.

For the library to work on android, the following packages must be added to the project (Shown in the gradle style)
```gradle
dependencies {
// gRPC
implementation 'io.grpc:grpc-okhttp:1.60.0'
implementation 'io.grpc:grpc-protobuf:1.40.1'
implementation 'io.grpc:grpc-stub:1.60.0'
compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+
implementation 'com.fasterxml.jackson.core:jackson-core:2.10.1'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.1'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.1'
}
```

Note that the minimum android SDK version for this package is 26.

# Usage
Expand Down
1 change: 1 addition & 0 deletions concordium-android-sdk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/target
/native/*
/delombok

Loading

0 comments on commit 7488808

Please sign in to comment.