Publish SNAPSHOT to GitHub Packages with Gradle
Asked Answered
C

0

8

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

Cysticercoid answered 9/9, 2021 at 15:4 Comment(6)
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?Homogeneous
@Homogeneous on 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.Cysticercoid
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 answerHomogeneous
@Homogeneous 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 refreshCysticercoid
When you're looking at your packages - github.com/<ORGANIZATION>/<PROJECT>/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 packagesHomogeneous
@Homogeneous I am definitely not seeing multiple SNAPSHOT entries. I see the first one, and then subsequent ones never appear anywhere.Cysticercoid

© 2022 - 2024 — McMap. All rights reserved.