diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..8070784 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,37 @@ +name: Publish + +on: + workflow_dispatch: {} + +jobs: + publsh: + name: Publish + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@master + + - name: Setup Test Java Runtime + id: setup-test-jre + uses: actions/setup-java@v1 + with: + java-version: 17 + architecture: x64 + + - name: Configure GPG Key + run: | + set -ex + echo $GPG_SIGNING_PRIVKEY | base64 --decode | gpg --import --batch --yes --pinentry-mode loopback --passphrase "$GPG_SIGNING_PASSPHRASE" + env: + GPG_SIGNING_PRIVKEY: ${{ secrets.GPG_SIGNING_PRIVKEY }} + GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSPHRASE }} + + - name: Publish package + run: | + ./gradlew publish -Dorg.gradle.project.nexusUsername=$NEXUS_USERNAME -Dorg.gradle.project.nexusPassword=$NEXUS_PASSWORD -Dorg.gradle.project.signing.gnupg.keyName=$GPG_SIGNING_KEYID -Dorg.gradle.project.signing.gnupg.passphrase=$GPG_SIGNING_PASSPHRASE + env: + NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} + NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} + GPG_SIGNING_KEYID: ${{ secrets.GPG_SIGNING_KEYID }} + GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSPHRASE }} diff --git a/README.md b/README.md index 65591ad..53891cd 100644 --- a/README.md +++ b/README.md @@ -71,4 +71,7 @@ The test suite can be ran with `gradle test` ## Deployment -Here is a useful [guide](http://www.albertgao.xyz/2018/01/18/how-to-publish-artifact-to-maven-central-via-gradle/) for deploying to Maven. \ No newline at end of file +1. Run the "Publish" action in GitHub. +2. On [Nexus Repository Manager](https://oss.sonatype.org/#stagingRepositories) find the staging repository and click "Close". +3. Click "Refresh" until the status goes from `open` to `closed`. +4. Click "Release". diff --git a/build.gradle b/build.gradle index 86daa3a..0ce91f7 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.github.kt3k.coveralls' version '2.12.0' id 'jacoco' id 'maven-publish' + id 'signing' } // Apply the java plugin to add support for Java @@ -18,18 +19,12 @@ task fatJar(type: Jar) { configurations.all { } -// In this section you declare where to find the dependencies of your project repositories { - // Use 'jcenter' for resolving your dependencies. - // You can declare any Maven/Ivy/file repository here. - jcenter() + mavenCentral() } - - version = '4.3.0' - // In this section you declare the dependencies for your production and test code dependencies { implementation 'com.fasterxml.jackson.core:jackson-core:2.9.9' @@ -94,4 +89,13 @@ publishing { } } } + repositories { + maven { + url "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username = project.findProperty("nexusUsername") + password = project.findProperty("nexusPassword") + } + } + } }