How to publish your written library inside your github repository to your personal github package registry?
- you need a github account
- your code must be inside the repository
- your code must compile
- every push consumes 1 github action
- this guide is for java-8 but you can do this for java-x too
- you must be the repository owner
- you need a github access token
- you must now how to add a secret to github
- you want maven for your dependency management
- 1 action for deploy
- deploy action listening for new tags eclipse-create-tags
- java-8
- maven
- status badge
This examples has all includings links and examples for the own repository, please modify the links for your own
- Open your pom.xml and add the following distributedManagement if its not already inside your pom.xml
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<!-- https://maven.pkg.github.com/<github-user>/<repository> -->
<url>https://maven.pkg.github.com/fo0/java-gh-package-registry-example</url>
</repository>
</distributionManagement>
- go to your github actions
- create your action for deploy workflow
- line 7: listening for new created releases
- line 15: java-version
- line 17: path to your <pom.file>
- line 19: name of your github-secret for your github-token
- commit something
- create a new tag i.e. v0.1
- check the github actions there should be one new tasks. Starting with deploy.
- open package-registry after first task deploy is finished
- creating a badge
There are two ways to access the library
- via github
- TODO: via maven central (including a new action)
- create or open the maven .settings.xml and add your github account informations to access the github package-registry (currently its a limitation of github)
<servers>
<server>
<id>github</id>
<username>YOUR_USERNAME</username>
<password>YOUR_AUTH_TOKEN</password>
</server>
</servers>
- open your java-project where you want to use the new library
- navigate to the pom.xml
- add your library dependency, you can copy it from your github package-registry