How to test pushing to GitHub Package Registry via a GitHub Action?

I’ve pushed my 1.0 JAR to the GitHub package registry, works great!

I’ve now written a GitHub Action to publish automatically to the registry when I create a tag.

How can I test this action? Since packages are immutable, I am afraid to make a mistake and have a bad JAR I can’t ever delete.

This is the untested part of my action that I am hoping works:

run: |
mkdir ~/.m2
echo "<settings><servers><server><id>github</id><username>USERNAME</username><password>${GITHUB_TOKEN}</password></server></servers></settings>" > ~/.m2/settings.xml
mvn deploy

And the corresponding repository information is in the pom.xml file.

Suggestions?

The setup-java action has detals on publishing maven packages to the package registry https://github.com/actions/setup-java#publishing-using-apache-maven.  As far as testing goes I would recommend creating a different repo if you want to delete everything after your publishing tests are complete.

1 Like