Skip to content

publish to maven central #39

@sebthom

Description

@sebthom

Please publish this useful plugin to Maven Central. The process to do so is simple and can be fully automated. https://central.sonatype.org/publish/publish-portal-maven/

We are using this config:

CI step:

- name: Release with Maven
  env:
    GITHUB_USER: ${{ github.actor }}
    GITHUB_API_KEY: ${{ secrets.GH_API_TOKEN }}
    SIGN_KEY: ${{ secrets.GPG_SIGN_KEY }}
    SIGN_KEY_PASS: ${{ secrets.GPG_SIGN_KEY_PWD }}
    SONATYPE_OSSRH_USER: ${{ secrets.SONATYPE_OSSRH_USER }}
    SONATYPE_OSSRH_USER_TOKEN: ${{ secrets.SONATYPE_OSSRH_USER_TOKEN }}
  run: |
    set -eu

    # https://github.community/t/github-actions-bot-email-address/17204
    git config user.name "github-actions[bot]"
    git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
    mvn
       -DdryRun=${DRY_RUN} \
       -Dresume=false \
       -DreleaseVersion=${inputs.RELEASE_VERSION} \
       -DdevelopmentVersion=${inputs.NEXT_DEV_VERSION} \
       clean release:clean release:prepare release:perform

settings.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">

   <servers>
      <server>
         <id>sonatype-ossrh</id>
         <username>${env.SONATYPE_OSSRH_USER}</username>
         <password>${env.SONATYPE_OSSRH_USER_TOKEN}</password>
      </server>
      <server>
         <id>github-commits</id>
         <username>${env.GITHUB_USER}</username>
         <password>${env.GITHUB_API_KEY}</password>
      </server>
   </servers>

</settings>

project.xml

<project>
   <properties>
      <!--
         use credentials from settings.xml for server with id "github-commits" during maven release
         http://maven.apache.org/maven-release/maven-release-plugin/faq.html#credentials
         https://issues.apache.org/jira/browse/MRELEASE-420
      -->
      <project.scm.id>github-commits</project.scm.id>

      <nexus-staging-maven-plugin.autoReleaseAfterClose>true</nexus-staging-maven-plugin.autoReleaseAfterClose>
      <nexus-staging-maven-plugin.nexusUrl>https://oss.sonatype.org/</nexus-staging-maven-plugin.nexusUrl>
      <skip.nexus-staging-maven-plugin.deploy>${dryRun}</skip.nexus-staging-maven-plugin.deploy>
   </properties>
   <profiles>
      <profile>
         <id>deploy-releases-to-maven-central</id>

         <activation>
            <property>
               <name>env.DEPLOY_RELEASES_TO_MAVEN_CENTRAL</name>
               <value>true</value>
            </property>
         </activation>

         <build>
            <plugins>
               <plugin>
                  <!-- https://github.com/s4u/sign-maven-plugin -->
                  <!-- use a pure Java based GPG plugin instead of maven-gpg-plugin to allow easy cross platform builds -->
                  <groupId>org.simplify4u.plugins</groupId>
                  <artifactId>sign-maven-plugin</artifactId>
                  <version>1.0.1</version>
                  <executions>
                     <execution>
                        <id>sign@verify</id>
                        <phase>verify</phase>
                        <goals>
                           <goal>sign</goal>
                        </goals>
                     </execution>
                  </executions>
               </plugin>
               <plugin>
                  <artifactId>maven-deploy-plugin</artifactId>
                  <configuration>
                     <skip>true</skip>
                  </configuration>
               </plugin>
               <plugin>
                  <!-- https://help.sonatype.com/repomanager2/staging-releases/configuring-your-project-for-deployment -->
                  <groupId>org.sonatype.plugins</groupId>
                  <artifactId>nexus-staging-maven-plugin</artifactId>
                  <version>1.6.13</version>
                  <extensions>true</extensions>
                  <executions>
                     <execution>
                        <id>deploy@deploy</id>
                        <phase>deploy</phase>
                        <goals>
                           <goal>deploy</goal>
                        </goals>
                        <configuration>
                           <skipNexusStagingDeployMojo>${skip.nexus-staging-maven-plugin.deploy}</skipNexusStagingDeployMojo>
                           <autoReleaseAfterClose>${nexus-staging-maven-plugin.autoReleaseAfterClose}</autoReleaseAfterClose>
                           <serverId>sonatype-ossrh</serverId>
                           <nexusUrl>${nexus-staging-maven-plugin.nexusUrl}</nexusUrl>
                        </configuration>
                     </execution>
                  </executions>
               </plugin>
            </plugins>
         </build>
      </profile>
   </profiles>
</project>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions