Generic instructions. Copy and customize for packages that we publish to Github Packages.
- Set up a personal access token for use with Github Packages. I recommend adding all the scopes they mention (repo, read:packages, write:packages, delete:packages) to cover most use cases during development.
- Add the token to your ~/.m2/settings.xml file
Example ~/.m2/settings.xml file:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<username>USERNAME</username>
<password>TOKEN</password>
</server>
</servers>
</settings>Replace USERNAME with your Github user name. Replace TOKEN with the personal access token you set up for Github Packages.
In the package project's pom.xml file, add a distribution management section:
<distributionManagement>
<repository>
<id>github</id>
<name>test-package on Github Packages</name>
<url>https://maven.pkg.github.com/pcheah/test-package</url>
</repository>
</distributionManagement>There is a default publishing location if you do not have a distribution management section but if we plan to publish multiple packages to the same repository, we do need this section.
Then publish the package to Github Packages using Maven:
$ mvn deployAdd this repository to the repositories section in pom.xml:
<repositories>
<repository>
<id>github</id>
<name>test-package on GitHub Packages</name>
<url>https://maven.pkg.github.com/pcheah/test-package</url>
</repository>
</repositories>Then add this dependency to the dependencies section in pom.xml:
<dependencies>
<dependency>
<groupId>com.icetec</groupId>
<artifactId>test-package</artifactId>
<version>0.1</version>
</dependency>
</dependencies>