Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 1
Message 11 of 19

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 12 of 19

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 13 of 19

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 14 of 19

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 15 of 19

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 16 of 19

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 17 of 19

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!

Copilot Lvl 2
Message 18 of 19

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.

 

This is strange because the docs clearly state that you can deploy multiple packages (though I'm having the same problem - getting a 400 error after getting one deploy to work half-way).

 

 

Copilot Lvl 3
Message 19 of 19

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

You can deploy mutiple packages, but you cannot deploy mutable packages.

 

This means that you cannot publish a SNAPSHOT package again, such as publish a `1.0-SNAPSHOT` package, and after updating something you cannot publish this package with version `1.0-SNAPSHOT` again(This is strange for snapshot packages).

 

So the only way to update your package is to publish a new version of you package.