From 94c6ba15a6824536f569eb026f16e4bde6f8d3ce Mon Sep 17 00:00:00 2001 From: carl Date: Fri, 15 Jul 2022 11:35:30 +0100 Subject: [PATCH] migrate to gradle --- .github/workflows/gradle.yml | 27 +++++++++++++++++++++++++++ .github/workflows/publish.yml | 30 ++++++++++++++++++++++++++++++ build.gradle | 20 ++++++++++---------- 3 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/gradle.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 000000000..d03741290 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,27 @@ +name: Java CI with Gradle + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'temurin' + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew clean build \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..04c8b5a4f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,30 @@ +name: Publish package to GitHub Packages and Maven Central +on: + release: + types: [created] +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Publish package + uses: gradle/gradle-build-action@v2 + with: + arguments: publish + env: + GPG_SIGNING_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }} + GPG_SIGNING_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index e1b2f83a8..f98c84f16 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,3 @@ - - plugins { id 'java-library' id 'signing' @@ -10,7 +8,7 @@ plugins { apply plugin: 'java' group = 'network.casper' -version='0.3.7' +version='0.3.10' sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -63,7 +61,7 @@ jar { task casperJar(type: Jar) { archiveBaseName = 'casper-java-sdk' - archiveVersion = '0.3.6' + archiveVersion = '0.3.10' manifest { attributes 'Main-Class': 'com.casper.sdk.CasperSdk' } @@ -83,8 +81,8 @@ publishing { 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') + username = System.getenv('OSSRH_USERNAME') + password = System.getenv('OSSRH_PASSWORD') } } maven { @@ -146,12 +144,14 @@ publishing { } } + jar { + archiveClassifier = '' + } + // Reference at https://docs.gradle.org/current/userguide/signing_plugin.html#sec:in-memory-keys signing { - def signingKey = System.getenv('MAVEN_GPG_KEY') ?: findProperty('MAVEN_GPG_KEY') - def signingKeyPassword = System.getenv('MAVEN_GPG_PASSPHRASE') ?: findProperty('MAVEN_GPG_PASSPHRASE') - - + def signingKey = System.getenv('OSSRH_GPG_SECRET_KEY') ?: findProperty('OSSRH_GPG_SECRET_KEY') + def signingKeyPassword = System.getenv('OSSRH_GPG_SECRET_KEY_PASSWORD') ?: findProperty('OSSRH_GPG_SECRET_KEY_PASSWORD') useInMemoryPgpKeys(signingKey, signingKeyPassword) sign publishing.publications.mavenJava