Skip to content

guide for creating a library including package-registry deployment

License

Notifications You must be signed in to change notification settings

fo0/java-gh-package-registry-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Publish package to GitHub Packages

How to publish your written library inside your github repository to your personal github package registry?

first of all there are some requirements for this guide

  • 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

what is my configuration?

Let's start!

This examples has all includings links and examples for the own repository, please modify the links for your own

  1. 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>
  1. go to your github actions
  2. 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
  1. commit something
  2. create a new tag i.e. v0.1
  3. check the github actions there should be one new tasks. Starting with deploy.
  4. open package-registry after first task deploy is finished
  5. creating a badge

How to access the library now?

There are two ways to access the library

  • via github
  • TODO: via maven central (including a new action)
  1. 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>
  1. open your java-project where you want to use the new library
  2. navigate to the pom.xml
  3. add your library dependency, you can copy it from your github package-registry