From 50195691b809f0c2cc2081016aa61174cc5aa9f4 Mon Sep 17 00:00:00 2001 From: Mateusz Pietryga Date: Mon, 2 Aug 2021 00:51:25 +0200 Subject: [PATCH] Use Github actions and repository secrets to create Maven Central deployment --- .github/workflows/release-new-version.yml | 42 +++++++++++++++++ pom.xml | 57 ++++++++++++++++++++++- 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-new-version.yml diff --git a/.github/workflows/release-new-version.yml b/.github/workflows/release-new-version.yml new file mode 100644 index 000000000..735b73a5a --- /dev/null +++ b/.github/workflows/release-new-version.yml @@ -0,0 +1,42 @@ +name: Release New Version +on: + workflow_dispatch: + inputs: + releaseVersion: + description: 'Release version' + required: false + +env: + MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn + JAVA_TOOL_OPTIONS: -Duser.name=io.github.java-native + GITHUB_BOT_NAME: github-actions + GITHUB_BOT_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com + +jobs: + maven-central-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: git config --global user.email "${GITHUB_BOT_EMAIL}" + - run: git config --global user.name "${GITHUB_BOT_NAME}" + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: 11 + distribution: temurin + server-id: ossrh + server-username: OSSRH_TOKEN_USERNAME + server-password: OSSRH_TOKEN_PASSWORD + gpg-private-key: ${{ secrets.JAVA_NATIVE_PGP_KEY }} + gpg-passphrase: PGP_KEY_PASSPHRASE + - name: Set release version if provided as input + if: github.event.inputs.releaseVersion != '' + run: echo "VERSIONS=-DreleaseVersion=${{ github.event.inputs.releaseVersion }}" >> $GITHUB_ENV + - name: Publish artifacts to Maven Central + run: mvn -B release:prepare release:perform -P package,maven-central-release ${VERSIONS} + env: + OSSRH_TOKEN_USERNAME: ${{ secrets.OSSRH_TOKEN_USERNAME }} + OSSRH_TOKEN_PASSWORD: ${{ secrets.OSSRH_TOKEN_PASSWORD }} + PGP_KEY_PASSPHRASE: ${{ secrets.JAVA_NATIVE_PGP_KEY_PASSPHRASE }} + - name: Push changes back to repo + run: git push && git push --tags --force diff --git a/pom.xml b/pom.xml index a7dd300ce..8c7dcb8d2 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,7 @@ scm:git:https://github.com/java-native/jssc.git scm:git:git@github.com:java-native/jssc.git https://github.com/java-native/jssc + HEAD @@ -63,10 +64,13 @@ 3.2.0 3.8.0 3.0.0-M3 + 3.0.1 3.1.1 3.1.1 3.6.0 + 1.6.7 1.7.0 + 3.0.0-M4 1.1 3.0.1 3.0.0-M4 @@ -447,7 +451,7 @@ attach-sources - jar + jar-no-fork @@ -574,5 +578,56 @@ + + maven-central-release + + + + org.apache.maven.plugins + maven-gpg-plugin + ${plugin.gpg.version} + + + sign-artifacts + verify + + sign + + + + + java-native + gpg.passphrase + + --pinentry-mode + loopback + + + + + org.apache.maven.plugins + maven-release-plugin + ${plugin.release.version} + + v@{project.version} + false + true + deploy + + + + org.sonatype.plugins + nexus-staging-maven-plugin + ${plugin.nexus-staging.version} + true + + ossrh + https://oss.sonatype.org/ + + + + + +