From 0dfdf5257097e57ea9bead170e8eeb62647d57d8 Mon Sep 17 00:00:00 2001 From: Benjamin Schulte Date: Fri, 5 Feb 2021 14:04:39 +0100 Subject: [PATCH] Publish releases via GHA --- .github/workflows/publish_release.yml | 33 +++++++++++++++++++++++++++ publish.gradle | 3 ++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish_release.yml diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml new file mode 100644 index 0000000..cec1c0f --- /dev/null +++ b/.github/workflows/publish_release.yml @@ -0,0 +1,33 @@ +name: Compile and publish release + +on: + release: + types: [published] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build and test + run: ./gradlew clean ashley:test + - name: Import GPG key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@v3 + with: + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + - name: Release build deploy + env: + NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} + NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} + run: + ./gradlew clean uploadArchives -PRELEASE=true -Psigning.gnupg.keyId=${{ secrets.GPG_KEYID }} -Psigning.gnupg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Psigning.gnupg.keyName=${{ secrets.GPG_KEYID }} diff --git a/publish.gradle b/publish.gradle index b5fc682..f7794d3 100644 --- a/publish.gradle +++ b/publish.gradle @@ -14,7 +14,7 @@ def sonatypeRepositoryUrl //set build variables based on build type (release, continuous integration, development) if(hasProperty("RELEASE")) { isReleaseBuild = true - sonatypeRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + sonatypeRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" println "Performing release build" } else if (hasProperty("SNAPSHOT")) { isCiBuild = true @@ -56,6 +56,7 @@ artifacts { if(isReleaseBuild) { signing { + useGpgCmd() sign configurations.archives } } else {