This repository serves demo purpose to show how to setup your project to deploy package with maven and github actions
In pom.xml define distributionManagement section
<distributionManagement>
<repository>
<id>github</id>
<name>OWNER</name>
<url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
</repository>
</distributionManagement>Replace OWNER and REPOSITORY with your user and repository names.
Define your github server:
<servers>
<server>
<id>github</id>
<username>${env.GITHUB_USER}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>You don't have to add any environment variables, user and token are available by default.
Define profile:
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>Use same <url> you used in POM file
Example of workflow can be found in .github/workflows/
This workflow is going to:
- Be triggered on push to
mainbranch - Parse current version of your artifact
- Generate new version of artifact
- Commit and push new version of POM file
- Build and publish new package
Make sure your workflow has read/write permissions in order to push version change in POM file. It can be done in repository settings as described here