Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publish to maven central #39

Open
sebthom opened this issue May 19, 2023 · 1 comment
Open

publish to maven central #39

sebthom opened this issue May 19, 2023 · 1 comment

Comments

@sebthom
Copy link

sebthom commented May 19, 2023

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-guide/

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>
@jesse-gallagher
Copy link
Member

This is definitely been on my list for this and a couple other projects for a while now, but I keep not quite getting around to it. This project is a perfect candidate, though, and I'll aim to look into setting up some GitHub actions to handle it for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants