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
42 changes: 26 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ env:
IMAGE_NAME: ${{ github.repository_owner }}/fabric-javaenv

jobs:
# Publishing steps to both the Github Packages and the Sonatype
publishjars:
strategy:
fail-fast: false
matrix:
publish_target:
- publishAllPublicationsToGithubPackagesRepository
- publishAllPublicationsToReleaseRepository
publish-github:
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -34,18 +27,35 @@ jobs:
distribution: "temurin"
java-version: 21
- uses: gradle/actions/setup-gradle@v4
- name: Push to registry ${{ matrix.publish_target }}
- name: Publish to GitHub Packages
run: |
set -xev
./gradlew -Psigning.key="${SIGNING_KEY}" -Psigning.password="${SIGNING_PASSWORD}" -PossrhUsername="${OSSRH_USER}" -PossrhPassword="${OSSRH_PASSWORD}" ${TARGET}
./gradlew publishAllPublicationsToGitHubRepository
env:
SIGNING_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
SIGNING_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
OSSRH_USER: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
TARGET: ${{ matrix.publish_target }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-maven:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 21
- uses: gradle/actions/setup-gradle@v4
- name: Publish to Maven Central
run: |
./gradlew publishAllPublicationsToStagingRepository
./gradlew jreleaserDeploy --stacktrace
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }}

docker-build-push:
name: Push Docker image
runs-on: ${{ matrix.arch.runner }}
Expand Down
159 changes: 82 additions & 77 deletions fabric-chaincode-shim/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

plugins {
id 'maven-publish'
id 'jacoco'
id 'signing'
id 'org.jreleaser' version '1.18.0'
id 'jacoco'
id 'pmd'
}

Expand Down Expand Up @@ -137,7 +138,7 @@ jacocoTestCoverageVerification {
test.finalizedBy(jacocoTestReport)
test.finalizedBy(jacocoTestCoverageVerification)

task licenseCheck {
tasks.register('licenseCheck') {
group = "license"
description = "Checks the License part of each source file"

Expand All @@ -146,34 +147,37 @@ task licenseCheck {
def missing = new LinkedList<File>()
sourceSets.forEach {
sourceSet ->
sourceSet.allSource.findAll { !it.path.contains("build") && !(it.path.contains("test") && it.path.contains("resources"))}.each {
sourceSet.allSource.findAll {
!it.path.contains("build") &&
!(it.path.contains("test") && it.path.contains("resources"))
}.each {
file ->
if (!file.name.contains("json")){
BufferedReader r = new BufferedReader(new FileReader(file))
def line, hasSPDX = false, hasTraditional = false
while ((line = r.readLine()) != null) {
if (line.contains("SPDX-License-Identifier")) {
hasSPDX = true
break
if (!file.name.contains("json")) {
BufferedReader r = new BufferedReader(new FileReader(file))
def line, hasSPDX = false, hasTraditional = false
while ((line = r.readLine()) != null) {
if (line.contains("SPDX-License-Identifier")) {
hasSPDX = true
break
}
if (line.contains("http://www.apache.org/licenses/LICENSE-2.0")) {
hasTraditional = true
break
}
}
if (line.contains("http://www.apache.org/licenses/LICENSE-2.0")) {
hasTraditional = true
break
}
}
if (!hasSPDX) {
if (hasTraditional) {
noSPDX.add(file)
} else {
missing.add(file)
if (!hasSPDX) {
if (hasTraditional) {
noSPDX.add(file)
} else {
missing.add(file)
}
}
}
}
}
}

if (noSPDX.isEmpty()) {
println "All remaining files have Apache 2.0 headers"
println "All remaining files have Apache 2.0 headers."
} else {
println "We are standardizing with the SPDX style license headers."
println "The following files contain the traditional license headers which are still valid:"
Expand Down Expand Up @@ -212,17 +216,13 @@ javadoc {

classpath = sourceSets.main.runtimeClasspath

javadoc.options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('Xwerror', '-quiet')
options.overview = "src/main/java/org/hyperledger/fabric/overview.html"
}

if (JavaVersion.current().isJava8Compatible()) {
project.tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:all', '-quiet')
options.addStringOption('Xwerror', '-quiet')
}
}

def final stagingDeployUrl = layout.buildDirectory.dir('staging-deploy')

publishing {
publications {
Expand All @@ -235,10 +235,12 @@ publishing {
name = 'JavaChaincodeShim'
packaging = 'jar'
description = 'Hyperledger Fabric Java Chaincode Shim'
url = 'http://www.hyperledger.org/'
url = 'https://hyperledger.github.io/fabric-chaincode-java/'

scm {
url = 'https://github.com/hyperledger/fabric-chaincode-java.git'
connection = 'scm:git:https://github.com/hyperledger/fabric-chaincode-java.git'
developerConnection = 'scm:git:ssh://github.com:hyperledger/fabric-chaincode-java.git'
url = 'https://github.com/hyperledger/fabric-chaincode-java'
}
licenses {
license {
Expand All @@ -248,26 +250,16 @@ publishing {
}

developers {
developer {
id = 'gennadylaventman'
name = 'Gennady Laventman'
email = '[email protected]'
}
developer {
id = 'luiss'
name = 'Luis Sanchez'
email = '[email protected]'
}
developer {
id = 'C0rWin'
name = 'Artem Barger'
email = '[email protected]'
}
developer {
id = 'denyeart'
name = 'David Enyeart'
email = '[email protected]'
}
developer {
id = 'bestbeforetoday'
name = 'Mark S. Lewis'
email = '[email protected]'
}
}
}
}
Expand All @@ -276,17 +268,12 @@ publishing {

repositories {
maven {
name = "release"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = project.findProperty('ossrhUsername')
password = project.findProperty('ossrhPassword')
}

name = "Staging"
url = stagingDeployUrl
}

maven {
name = "GitHubPackages"
name = "GitHub"
url = "https://maven.pkg.github.com/hyperledger/fabric-chaincode-java"
credentials {
username = System.getenv("GITHUB_ACTOR")
Expand All @@ -297,25 +284,42 @@ publishing {
}

signing {
println "Signing"
if (project.findProperty('signing.key')) {
def signingKey = project.findProperty('signing.key')
def signingPassword = project.findProperty('signing.password')
useInMemoryPgpKeys(signingKey, signingPassword)

sign publishing.publications.shim
println "... signed"
} else {
println "... no keys to use "
required = { gradle.taskGraph.hasTask(":${project.name}:publishShimPublicationToStagingRepository") }

def signingKey = findProperty('signingKey')
def signingPassword = findProperty('signingPassword')
useInMemoryPgpKeys(signingKey, signingPassword)

sign publishing.publications.shim
}

jreleaser {
gitRootSearch = true
deploy {
maven {
mavenCentral {
sonatype {
active = 'ALWAYS'
url = 'https://central.sonatype.com/api/v1/publisher'
sign = false
stagingRepository(file(stagingDeployUrl).toString())
}
}
}
}
release {
github {
enabled = false
}
}
}

// Need to specify the sourcesJar task BEFORE the java{withSourcesJar()} so that it picks up the duplicatesStratergy
// otherwise this fails with a duplicates error.
// (see https://github.com/gradle/gradle/issues/17236)

task sourcesJar(type: Jar) {
duplicatesStrategy = 'include'
tasks.register('sourcesJar', Jar) {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
Expand All @@ -332,16 +336,16 @@ build.dependsOn licenseCheck
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

tasks.withType(Test) {
tasks.withType(Test).configureEach {

environment "CORE_PEER_LOCALMSPID", "mymsp"

testLogging {
// set options for log level LIFECYCLE
events TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
Expand All @@ -350,22 +354,23 @@ tasks.withType(Test) {
// set options for log level DEBUG and INFO
debug {
events TestLogEvent.STARTED,
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT
exceptionFormat = TestExceptionFormat.FULL
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat

afterSuite { desc, result ->
afterSuite {desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' +
('-' * repeatLength))
}
}
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
9 changes: 4 additions & 5 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.