Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 11 of 23

Re: GitHub package registry as Maven repo - trouble uploading artifact

Thanks for your post, it was quite helpful. I noticed  mvn deploy fails on my end also, but like you rightly pointed, using deploy-file on one jar file works. Interestingly, you can only have one jar, seems any any attempt to upload multiple jars for a single deployment fails. This is a terrible experience, I spent most of my day troubleshooting this.

 

This does not work:

mvn deploy:deploy-file \
-DrepositoryId=github \
-Dfile=target/apigateway-feign-0.0.2-SNAPSHOT.M4.jar \
-Dsources=target/apigateway-feign-0.0.2-SNAPSHOT.M4-sources.jar \
-Djavadoc=target/apigateway-feign-0.0.2-SNAPSHOT.M4-javadoc.jar \
-Durl=https://maven.pkg.github.com/_OWNER/_REPOSITORY \
-DpomFile=pom.xml

However, this works:

 

mvn deploy:deploy-file \
-DrepositoryId=github \
-Dfile=target/apigateway-feign-0.0.2-SNAPSHOT.M6.jar \
-Durl=https://maven.pkg.github.com/_OWNER/_REPOSITORY \
-DpomFile=pom.xml

 

 

 

Copilot Lvl 2
Message 12 of 23

Re: GitHub package registry as Maven repo - trouble uploading artifact

I noticed that I was able to deploy to the github registry on my laptop, so I looked at the maven versions used.  The ubuntu-latest runner is using 3.6.1, and I was pretty far behind at 3.0.5.  The earliest    Looking at the maven version on ubuntu-latest in github actions, I was pretty far behind at 3.0.5   After verifying that I coud reproduce using the 3.6.1 maven container, I found the oldest published version on docker hub, and replaced my 

 

 

mvn deploy

 with

 

       docker run --rm -v $HOME/.m2:/root/.m2 \
        -v $(pwd):/work -w /work  \
        maven:3.3.1-jdk-8 mvn deploy
 
 
I'm curious to figure out which version of maven it becomes incompatible, but not curious enough to do the work :)

 

Highlighted
Copilot Lvl 3
Message 13 of 23

Re: GitHub package registry as Maven repo - trouble uploading artifact

Just a small update,  I can now publish jars with classifiers, using mvn deploy - by turning off the wagon http pool. 

mvn -B -e -Dmaven.wagon.http.pool=false clean deploy

Ground Controller Lvl 1
Message 14 of 23

Re: GitHub package registry as Maven repo - trouble uploading artifact

We have had the exact same issue (https://github.com/navikt/helse-streams/packages) and finally got it to work when we switched the token from `GITHUB_TOKEN` (the one provided in a github action) with a personal access token.

Ground Controller Lvl 1
Message 15 of 23

Re: GitHub package registry as Maven repo - trouble uploading artifact

I am also experiencing the same issue when building a simple Java project. I also tried with the Github Action GITHUB_TOKEN and also with a Personal Access token. Both did not work. 


Here is the error message:https://github.com/philpotisk/java-tomcat-maven-example/commit/91653369d5d529e18960568948e1616adc4b4...

 

Thx for suggestions what I should try next.

Ground Controller Lvl 1
Message 16 of 23

Re: GitHub package registry as Maven repo - trouble uploading artifact

Hi,

we had the same issue, and I have tried many possible solution. The solution we are currently on is this:

 

project.afterEvaluate {
    publishing {
        publications {
            mavenPublish(MavenPublication) {
                groupId 'my.group.id'
                artifactId 'my-artifact-id'
                version = android.defaultConfig.versionName
            }
        }
    }
}
project.ext {
    mavPublishToRemoteRepo = true
    mavRemoteRepoUser = "myUsername"
    mavRemoteRepoPassword = "my-github-personal-access-token"
    mavRepoRemoteUrl = "https://maven.pkg.github.com/org/repo"
}

apply from: 'https://raw.githubusercontent.com/sky-uk/gradle-maven-plugin/master/gradle-mavenizer.gradle'

Hope this helps!

Copilot Lvl 2
Message 17 of 23

Re: GitHub package registry as Maven repo - trouble uploading artifact

You can try to upload file manually:

 

curl -X PUT \
"https://maven.pkg.github.com/OWNER/REPOSITORY/GROUP/ID/ARTIFACT_ID/VERSION/YOUR_JAR.jar" \
-H "Authorization: token <PERSONAL_ACCESS_TOKEN>" \
--upload-file "/full/path/to/file" -vvv

Example:

curl -X PUT \
"https://maven.pkg.github.com/igabaydulin/github-package-registry-example/com/github/igabaydulin/groovy-ping/1.0.0/groovy-ping-1.0.0.jar" \
-H "Authorization: token <PERSONAL_ACCESS_TOKEN>" \
--upload-file "/full/path/to/groovy-ping-1.0.0.jar" -vvv

Output example:

Error: "groovy-ping-1.0.0.jar" in version 1.0.0 of "com.github.igabaydulin.groovy-ping" has already been published.

Repo example: https://github.com/igabaydulin/github-package-registry-example

Copilot Lvl 2
Message 18 of 23

Re: GitHub package registry as Maven repo - trouble uploading artifact

I found that I got the 400 error when I set the repository url to

<url>https://maven.pkg.github.com/OWNER</url>  

But worked when I set it to

<url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>


Furthermore, I got it working from a Github Actions by adding a block like this:

name: Java CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Deploy to Github Package Registry
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: |
        mkdir ~/.m2
        echo "<settings><servers><server><id>github</id><username>OWNER</username><password>${GITHUB_TOKEN}</password></server></servers></settings>" > ~/.m2/settings.xml
        mvn deploy
Copilot Lvl 3
Message 19 of 23

Re: GitHub package registry as Maven repo - trouble uploading artifact

I have met the same issue.

In my case, I have deployed a SNAPSHOT version of my simple project. And after updating the project, I'd like to deploy the snapshot version again but Maven returns an error with status code 400 just like this issue. In the other side, all thing works well with RELEASE version of my simple project.

I guess there is something wrong(maybe bugs) with SNAPSHOT in GitHub Package Registry.

 

PS: to recurrent this issue, just create a simple maven project with a snapshot version(such as 1.0-SNAPSHOT), deploy it to GitHub Package Registry, and then update it and deploy with 1.0-SNAPSHOT again. Hope this helpful.

Copilot Lvl 3
Message 20 of 23

Re: GitHub package registry as Maven repo - trouble uploading artifact

Writing to GitHub I have got the message that GitHub Package Registry currently does not support mutable packages, whether your package is SNAPSHOT or not. So the only way to update your package is to publish a new package.

 

Hope GPR supports mutable packags ASAP!