From 8405c0dbda549094f66c423fe8c56edc691eb6fd Mon Sep 17 00:00:00 2001 From: jycr Date: Tue, 11 Jul 2023 10:48:43 +0200 Subject: [PATCH] Adds missing information for publishing to Maven Central --- .../workflows/publish_to_maven_central.yml | 57 +++++++++ pom.xml | 115 ++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 .github/workflows/publish_to_maven_central.yml diff --git a/.github/workflows/publish_to_maven_central.yml b/.github/workflows/publish_to_maven_central.yml new file mode 100644 index 000000000..9ae39dcb5 --- /dev/null +++ b/.github/workflows/publish_to_maven_central.yml @@ -0,0 +1,57 @@ +# This workflow will build a Java project with Maven and publish artifact to Maven Central (https://search.maven.org) +# +# After deploy to https://s01.oss.sonatype.org finished, manual steps is required : +# - Go to: https://s01.oss.sonatype.org/#stagingRepositories +# - Check upload and if all is right, "Close" corresponding Staging Repository +# - "Release" corresponding Staging Repository +# - Wait some hours and then check availability of release on Maven central: https://search.maven.org/search?q=g:io.ecocode +# +# Additional information: +# - https://docs.github.com/en/actions/publishing-packages/publishing-java-packages-with-maven#publishing-packages-to-the-maven-central-repository +# - https://blogs.itemis.com/en/github-actions-releasing-artifacts-into-maven-central + +name: Publish package to the Maven Central Repository + +on: + release: + types: [ published ] + +jobs: + publish: + name: Deploy to Maven central + runs-on: ubuntu-latest + + steps: + # Checks out a copy of project's repository. + - name: Checkout + uses: actions/checkout@v3 + + # Sets up the Java JDK, and also configures the Maven `settings.xml` file to add authentication for the + # `ossrh` repository using the `OSSRH_USERNAME` and `OSSRH_PASSWORD` environment variables. + - name: Set up Maven Central Repository + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + server-id: 'ossrh' # must match the serverId configured for the nexus-staging-maven-plugin in `pom.xml` + server-username: OSSRH_USERNAME + server-password: OSSRH_PASSWORD + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Substituted with the value stored in the referenced secret + gpg-passphrase: MAVEN_GPG_PASSPHRASE # Env var that holds the key's passphrase + + - name: Cache Maven packages + uses: actions/cache@v1 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + # Runs the Maven command to publish to the `ossrh` repository. + # The `OSSRH_USERNAME` environment variable will be set with the contents of your `OSSRH_USERNAME` secret, + # and the `OSSRH_PASSWORD` environment variable will be set with the contents of your `OSSRH_TOKEN` secret. + - name: Publish package + run: mvn --batch-mode deploy -Pmaven-central-publishing + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} diff --git a/pom.xml b/pom.xml index 0a13b79b0..a96d6de6e 100644 --- a/pom.xml +++ b/pom.xml @@ -22,6 +22,61 @@ + + + + Gilles Grousset + zippy1978@users.noreply.github.com + green-code-initiative + https://github.com/green-code-initiative + + + Maxime Malgorn + utarwyn@users.noreply.github.com + green-code-initiative + https://github.com/green-code-initiative + + + Geoffrey Lalloué + glalloue@users.noreply.github.com + green-code-initiative + https://github.com/green-code-initiative + + + David DE CARVALHO + dedece35@users.noreply.github.com + green-code-initiative + https://github.com/green-code-initiative + + + Olivier Le Goaër + olegoaer@users.noreply.github.com + green-code-initiative + https://github.com/green-code-initiative + + + Julien Hertout + jhertout@users.noreply.github.com + green-code-initiative + https://github.com/green-code-initiative + + + Jules Delecour + jules-delecour-dav@users.noreply.github.com + green-code-initiative + https://github.com/green-code-initiative + + + DUBOIS Maxime + mdubois81@users.noreply.github.com + green-code-initiative + https://github.com/green-code-initiative + + + ecocode-rules-specifications python-plugin @@ -247,4 +302,64 @@ + + + + maven-central-publishing + + + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + ossrh + https://s01.oss.sonatype.org/ + true + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.1.0 + + + sign-artifacts + verify + + sign + + + + + + + +