From 4e8db72c537fadd3ae23359937bd8e4177f3e7ea Mon Sep 17 00:00:00 2001 From: "Vincent A. Cicirello" Date: Wed, 22 Sep 2021 14:38:07 -0400 Subject: [PATCH] Create maven-publish.yml --- .github/workflows/maven-publish.yml | 65 +++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/maven-publish.yml diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml new file mode 100644 index 0000000..0d9b3e3 --- /dev/null +++ b/.github/workflows/maven-publish.yml @@ -0,0 +1,65 @@ +name: Maven Package + +on: + release: + types: [created] + +jobs: + publish: + + runs-on: ubuntu-latest + + env: + artifact_name: rho-mu + + steps: + - uses: actions/checkout@v2 + + - name: Get the release version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/} + + - name: Set up JDK 11 for deploy to OSSRH + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_CENTRAL_TOKEN + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Update package version + run: mvn versions:set -DnewVersion=${{ steps.get_version.outputs.VERSION }} + + - name: Publish to Apache Maven Central + run: mvn deploy -PossrhDeploy + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + + - name: Set up JDK 11 for deploy to github packages + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' + server-id: github + + - name: Publish to GitHub Packages Apache Maven + run: mvn deploy -PgithubDeploy + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload jar files to release as release assets + run: | + TAG=${GITHUB_REF/refs\/tags\//} + gh release upload ${TAG} target/${{ env.artifact_name }}-${{ steps.get_version.outputs.VERSION }}.jar + gh release upload ${TAG} target/${{ env.artifact_name }}-${{ steps.get_version.outputs.VERSION }}-sources.jar + gh release upload ${TAG} target/${{ env.artifact_name }}-${{ steps.get_version.outputs.VERSION }}-javadoc.jar + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}