6

I'm having a hard time publishing a Java library in its 0.0.1-SNAPSHOT version to GitHub Packages. The library is a Gradle project. It would appear that, when the version is not on GitHub (yet), it gets created successfully, however after that, it never gets updated/overwritten, and the only way to publish a new SNAPSHOT version is to physically delete the existing one. My build.gradle:

plugins {
    id 'java'
    id 'maven-publish'
}

version = '0.0.1-SNAPSHOT'

publishing {
    publications {
        maven(MavenPublication) {
            from components.java
        }
    }
    repositories {
        maven {
            url = "https://maven.pkg.github.com/myOrg/myRepo"
            credentials {
                username = "myUsername"
                password = "myPassword"
            }

        }
    }
}

When I do gradle publish (both locally or via GitHub actions), the log is nice and clean

> Task :compileJava UP-TO-DATE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :jar UP-TO-DATE
> Task :javadoc UP-TO-DATE
> Task :javadocJar UP-TO-DATE
> Task :sourcesJar UP-TO-DATE
> Task :generateMetadataFileForMavenPublication
> Task :generatePomFileForMavenPublication
> Task :publishMavenPublicationToQuotechRepository
> Task :publish

BUILD SUCCESSFUL in 50s
8 actionable tasks: 3 executed, 5 up-to-date

even a gradle clean, or wiping everything out doesn't make any difference. It seems that GitHub refuses to overwrite the existing SNAPSHOT with the new one. Checking timestamps on GitHub only points to the very first SNAPSHOT upload. Any clue how to get this to work? Shouldn't a standard Maven repository automatically overwrite SNAPSHOT versions every time a new one is pushed? Thanks

Nick Melis
  • 403
  • 1
  • 7
  • 19
  • I can confirm github SNAPSHOT publication works as expected. @Nick Melis Why are you certain the package does not get published? what is the use case you are seeing, as a user of the published package, that indicates it is not updated on github packages? – Sheinbergon Sep 22 '21 at 06:51
  • @Sheinbergon on https://github.com/myOrg/myRepo/packages/myPackageNumber I can see what artifacts were uploaded and when. All artifacts have also timestamps in their file names, and the timestamps simply don't match. That's how I can see that new SNAPSHOT artifacts don't get uploaded. Plus, when trying to fetch the artifact from another project, the new code simply isn't there. – Nick Melis Sep 22 '21 at 08:52
  • Meils. That's exactly what I thought. Have you tried disabling SNAPSHOT caching in gradle? configurations.all { resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } If that helps, I'll write a formal answer – Sheinbergon Sep 22 '21 at 09:00
  • @Sheinbergon tried that. The problem is not on refreshing dependencies, the problem is that the new SNAPSHOT never gets published in the first place, so there's nothing to refresh – Nick Melis Sep 22 '21 at 13:07
  • When you're looking at your packages - https://github.com///packages/ Are you not seeing multiple SNAPSHOT ENTRY dates on the side-bar? I'm asking because publication worked for me, when I published snapshots to GH packages – Sheinbergon Sep 22 '21 at 13:34
  • @Sheinbergon I am definitely not seeing multiple SNAPSHOT entries. I see the first one, and then subsequent ones never appear anywhere. – Nick Melis Sep 22 '21 at 14:14

1 Answers1

0

I think GitHub Packages do not support overriding the previous same version package until now, even if it is named with the SNAPSHOT suffix.

What we can do to override the previous same version package?

  1. Deleting the previous package by the API or workflow - https://docs.github.com/en/packages/learn-github-packages/deleting-and-restoring-a-package
  2. Publishing the new package - https://docs.github.com/en/packages/learn-github-packages/publishing-a-package
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Jun Wu
  • 1