How do you upload a Maven artifact to Github Packages using the command line?

I am trying to upload a Maven artifact I haven’t built to one my Organization’s GitHub package registry. I am using the deploy:deploy-file Maven plugin in order to do so. Here is the command I have been using:

mvn deploy:deploy-file -Dfile=[THE JAR FILE] -Durl=https://maven.pkg.github.com/[ORG] -Dregistry=https://maven.pkg.github.com/[ORG] -DgroupId=[GID] -DartifactId=[ARTIFACTID] -Dversion=[VERSION] -DgeneratePom=false-Dtoken=[MY GITHUB TOKEN]

As a result I am receiving 401 errors from Github. I have made sure that:

  • I have sufficient permissions inside of my Organization (currently Owner).
  • The token i am using is valid and has the appropriated scopes: I put all of them on to test.

Also, the github package page states:

\<!-- Just a single step: Deploy using a GitHub token --\>$ mvn deploy -Dregistry=https://maven.pkg.github.com/[org] -Dtoken=GH\_TOKEN

Why can’t I find any information in Maven documentation about registry or token parameters? Can I upload this file to the organization’s registry without any kind of XML configuration file, using only the cli?

Thanks in advance.

4 Likes

Were you able to figure out a solution? I’m having the same issue.

Thank you

Hi guys,

In my case, I set in settings.xml

<server>
    <id>github</id>
    <username>PASTE_HERE_YOUR_GITHUB_USER</username
    <password>PASTE_HERE_YOUR_GITHUB_TOKEN</password
</server>

then

mvn deploy:deploy-file -Dfile=[THE JAR FILE] -Durl=https://maven.pkg.github.com/[ORG]/[REPO]-DgroupId=[GID]  
-Dpacking=jar -DartifactId=[ARTIFACTID] -Dversion=[VERSION] - **DrepositoryId=github**

I hope that works

1 Like