GitHub action upload artifact to maven repository
Oct 12, 2022
Today I had the task to use GitHub actions to automatically publish an open source Java project to the maven repository. The following post should simply explain all steps.
Register account
- Register an account at: https://issues.sonatype.org/projects/OSSRH/issues/
- If your account was approved you can login to Nexus at: https://s01.oss.sonatype.org/
Generate GPG keys
Use the following commands to generate a new key pair and output the secret key to a file “private.pgp”
GitHub action
Create at your repository the following repository secrets:
- OSSRH_USERNAME = The username of your account from sonatype.org
- OSSRH_PASSWORD = The password of your account from sonatype.org
- GPG_PRIVATE_KEY = The content of the private.pgp file
- GPG_PASSPHRASE = The passphrase of your private key
Then you can simply use the following workflow file s.