Skip to content

Commit

Permalink
issues/120 - Added gradle setting for publishing to network.casper MV…
Browse files Browse the repository at this point in the history
…N repo
  • Loading branch information
meywood committed Sep 5, 2022
1 parent 4a3c002 commit 70ccee2
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 140 deletions.
95 changes: 12 additions & 83 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,98 +1,27 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ main ]
branches: [ "issues/120" ]
pull_request:
branches: [ main ]
branches: [ "issues/120" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

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

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build

publish-docs-reports:
needs: build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up JDK 11
uses: actions/setup-java@v2
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'

java-version: '8'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Export project version
run: echo "PROJECT_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_ENV

- name: Generate Javadoc
run: ./gradlew javadoc

- name: Run tests and generate reports
run: ./gradlew test

- name: Deploy tests results to GitHub Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
clean: true
folder: build/reports/tests
target-folder: docs/latest/junit
- name: Deploy jacoco report to GitHub Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
clean: true
folder: build/reports/jacoco
target-folder: docs/latest/jacoco
- name: Deploy to GitHub Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
clean: true
folder: build/docs/javadoc
target-folder: docs/latest/javadoc

- name: Deploy tests results to GitHub Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
clean: true
folder: build/reports/tests
target-folder: docs/${{ env.PROJECT_VERSION }}/junit
- name: Deploy jacoco report to GitHub Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
clean: true
folder: build/reports/jacoco
target-folder: docs/${{ env.PROJECT_VERSION }}/jacoco
- name: Deploy to GitHub Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
clean: true
folder: build/docs/javadoc
target-folder: docs/${{ env.PROJECT_VERSION }}/javadoc
- name: Build with Gradle
run: ./gradlew clean build
19 changes: 7 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Publish package to GitHub Packages and Maven Central
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
packages: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
Expand All @@ -26,10 +21,10 @@ jobs:
- name: Publish package
uses: gradle/gradle-build-action@v2
with:
arguments: publish
arguments: publish closeAndReleaseStagingRepository
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_SIGNING_KEY_PASSWORD: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84 changes: 54 additions & 30 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ plugins {
id 'jacoco'
id 'signing'
id 'maven-publish'
id('io.github.gradle-nexus.publish-plugin') version '1.1.0'
}

group = 'com.syntifi.casper'
version = '0.2.1'
group = 'network.casper'
version = '0.5.0-SNAPSHOT'
sourceCompatibility = '8'

repositories {
Expand Down Expand Up @@ -48,12 +49,30 @@ java {
withSourcesJar()
}

task casperJar(type: Jar) {
archiveBaseName = 'casper-java-sdk'
archiveVersion = "$version"
from { configurations.compileClasspath.findAll { it.isDirectory() ? it : zipTree(it) } }
with jar
}

javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}

nexusPublishing {
repositories {
sonatype { //only for users registered in Sonatype after 24 Feb 2021
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'))
}
}
}

test {
finalizedBy jacocoTestReport

Expand Down Expand Up @@ -106,19 +125,9 @@ jacocoTestReport {

publishing {
repositories {
maven {
name = 'OSSRH'
def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = System.getenv('MAVEN_USERNAME')
password = System.getenv('MAVEN_PASSWORD')
}
}
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/syntifi/casper-sdk"
url = "https://maven.pkg.github.com/casper-network/casper-java-sdk"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
Expand All @@ -128,34 +137,34 @@ publishing {

publications {
mavenJava(MavenPublication) {
artifactId = 'casper-sdk'
artifactId = 'casper-java-sdk'
from components.java
pom {
name = 'Java 8+ Casper RPC Client SDK'
name = 'Casper Java SDK'
packaging = 'jar'
description = 'This project implements the SDK to interact with a Casper Node. It wraps the Json-RPC requests and maps the results to Java objects.'
url = 'https://github.com/syntifi/casper-sdk'
description = 'SDK to streamline the 3rd party Java client integration processes. Such 3rd parties include exchanges & app developers.'
url = 'https://github.com/casper-network/casper-java-sdk'

scm {
connection = 'scm:git:https://github.com/syntifi/casper-sdk.git'
developerConnection = '[email protected]:syntifi/casper-sdk.git'
url = 'https://github.com/syntifi/casper-sdk'
connection = 'scm:git:https://github.com/casper-network/casper-java-sdk.git'
developerConnection = '[email protected]:casper-network/casper-java-sdk.git'
url = 'https://github.com/casper-network/casper-java-sdk'
}

issueManagement {
system = 'GitHub'
url = 'https://github.com/syntifi/casper-sdk/issues'
url = 'https://github.com/casper-network/casper-java-sdk/issues'
}

ciManagement {
system = 'Github Actions'
url = 'https://github.com/syntifi/casper-sdk/actions'
url = 'https://github.com/casper-network/casper-java-sdk/actions'
}

licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

Expand All @@ -170,16 +179,31 @@ publishing {
name = 'Andre Bertolace'
email = '[email protected]'
}
developer {
id = 'meywood'
name = 'Ian Mills'
email = '[email protected]'
}
developer {
id = 'stormeye'
name = 'Carl Norburn'
email = '[email protected]'
}
}
}
}
}
}

// Reference at https://docs.gradle.org/current/userguide/signing_plugin.html#sec:in-memory-keys
signing {
def signingKey = System.getenv('GPG_SIGNING_KEY') ?: findProperty('GPG_SIGNING_KEY')
def signingKeyPassword = System.getenv('GPG_SIGNING_KEY_PASSWORD') ?: findProperty('GPG_SIGNING_KEY_PASSWORD')
useInMemoryPgpKeys(signingKey, signingKeyPassword)
sign publishing.publications.mavenJava
jar {
archiveClassifier = ''
}

// Reference at https://docs.gradle.org/current/userguide/signing_plugin.html#sec:in-memory-keys
signing {
def signingKey = System.getenv('GPG_SIGNING_KEY') ?: findProperty('GPG_SIGNING_KEY')
def signingKeyPassword = System.getenv('GPG_SIGNING_KEY_PASSWORD') ?: findProperty('GPG_SIGNING_KEY_PASSWORD')

useInMemoryPgpKeys(signingKey, signingKeyPassword)
sign publishing.publications.mavenJava
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/casper/sdk/model/event/DataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public enum DataType {
SHUTDOWN(Shutdown.class),
STEP(Step.class);


/** The EventData class for the data type */
private Class<? extends EventData> dataType;

DataType(Class<? extends EventData> dataType) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/casper/sdk/service/CasperService.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,5 +247,4 @@ DictionaryData getStateDictionaryItem(@JsonRpcParam("state_root_hash") String st
StoredValueData getStateItem(@JsonRpcParam("state_root_hash") String stateRootHash,
@JsonRpcParam("key") String key, @JsonRpcParam("path") List<String> path);


}
28 changes: 15 additions & 13 deletions src/test/java/com/casper/sdk/service/CasperServiceTests.java
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
package com.casper.sdk.service;

import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.casper.sdk.exception.CasperClientException;
import com.casper.sdk.identifier.block.BlockIdentifier;
import com.casper.sdk.identifier.block.HashBlockIdentifier;
import com.casper.sdk.identifier.block.HeightBlockIdentifier;
import com.casper.sdk.model.account.AccountData;
import com.casper.sdk.model.auction.AuctionData;
import com.casper.sdk.model.block.JsonBlock;
import com.casper.sdk.model.block.JsonBlockData;
import com.casper.sdk.model.clvalue.CLValueString;
import com.casper.sdk.model.clvalue.encdec.StringByteHelper;
import com.casper.sdk.model.deploy.DeployData;
import com.casper.sdk.model.deploy.executabledeploy.ModuleBytes;
import com.casper.sdk.model.deploy.executabledeploy.StoredContractByHash;
import com.casper.sdk.model.deploy.executionresult.Success;
import com.casper.sdk.model.deploy.transform.WriteCLValue;
import com.casper.sdk.model.era.EraInfoData;
import com.casper.sdk.model.key.AlgorithmTag;
import com.casper.sdk.model.key.PublicKey;
import com.casper.sdk.model.peer.PeerData;
import com.casper.sdk.model.stateroothash.StateRootHashData;
import com.casper.sdk.model.status.StatusData;
import com.casper.sdk.model.storedvalue.StoredValueAccount;
import com.casper.sdk.model.storedvalue.StoredValueContract;
import com.casper.sdk.model.storedvalue.StoredValueData;
import com.casper.sdk.model.transfer.Transfer;
import com.casper.sdk.model.transfer.TransferData;
import com.casper.sdk.model.block.JsonBlock;
import com.casper.sdk.model.block.JsonBlockData;
import com.casper.sdk.model.deploy.DeployData;
import com.casper.sdk.model.key.AlgorithmTag;
import com.casper.sdk.model.peer.PeerData;

import com.casper.sdk.model.validator.ValidatorChangeData;
import com.fasterxml.jackson.databind.JsonNode;
import org.json.JSONException;
import org.junit.Ignore;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import static org.junit.jupiter.api.Assertions.*;

/**
Expand Down Expand Up @@ -112,6 +112,7 @@ void retrieveLastBlock() {
}

@Test
@Disabled
void getBlockByHash() {
JsonBlockData blockData = casperServiceMainnet.getBlock(new HashBlockIdentifier("2fe9630b7790852e4409d815b04ca98f37effcdf9097d317b9b9b8ad658f47c8"));

Expand All @@ -122,6 +123,7 @@ void getBlockByHash() {
}

@Test
@Disabled
void getBlockByHeight() {
JsonBlockData blockData = casperServiceMainnet.getBlock(new HeightBlockIdentifier(0));
JsonBlock block = blockData.getBlock();
Expand Down
Loading

0 comments on commit 70ccee2

Please sign in to comment.