Publish to github packages succeeds but package is not visible

I’ve added an action to publish on a release being created

name: Publish package to GitHub Packages
on:
  release:
    types: [created]
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v1
        with:
          java-version: 1.8
      - name: Publish package
        run: gradle publish
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

here’s the publishing section from build.gradle

publishing {
    repositories {
        maven {
            name = "GitHubPackages"
            url = "https://maven.pkg.github.com/dave99galloway/TypeSafeMapMap"
            credentials {
                username = System.getenv("GITHUB_ACTOR")
                password = System.getenv("GITHUB_TOKEN")
            }
        }

and the build output:-

 Publish package32s
    GITHUB_TOKEN: ***
Run gradle publish
  gradle publish
  shell: /bin/bash -e {0}
  env:
    JAVA_HOME_8.0.265_x64: /opt/hostedtoolcache/jdk/8.0.265/x64
    JAVA_HOME: /opt/hostedtoolcache/jdk/8.0.265/x64
    JAVA_HOME_8_0_265_X64: /opt/hostedtoolcache/jdk/8.0.265/x64
    GITHUB_TOKEN: ***

Welcome to Gradle 6.6.1!

Here are the highlights of this release:
 - Experimental build configuration caching
 - Built-in conventions for handling credentials
 - Java compilation supports --release flag

For more details see https://docs.gradle.org/6.6.1/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)
> Task :publish UP-TO-DATE

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.6.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 31s

but no package has been created! what’s going on?

Hi @dave99galloway,

Glad to see you in Github Community Forum!

GitHub has published the official document for How to use Gradle with GitHub package, please follow the doc for a fix.

publishing {
    repositories {
        maven {
            name = "GitHubPackages"
            url = uri("https://maven.pkg.github.com/OWNER/REPOSITORY")
            credentials {
                username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
                password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
            }
        }
    }
    publications {
        gpr(MavenPublication) {
            from(components.java)
        }
    }
}

Here is sample repro from github staff: https://github.com/clarkbw/github-registry-repro

Thanks.

1 Like

Hi @weide-zhou !

I tried your suggestion and looked at the sample repro which was a bit more similar to my build.gradle.

I could see I was missing the afterEvaluate block so I tried adding one . this didn’t work - when I reran the publish task again it succeeded but no packages were published.

here’s the tag I used :-


at commit:

I mention this as I’m going to back the change out of master since it failed.

Could you please advise what needs to go into build.gradle and into the .github/workflows/gradle-publish-mvn-gh.yml action file to get the publish action to actually publish the packages?

@weide-zhou actually it did work!


Now I need to figure out how I did it, and remove the ossrh job, and how to add the artifact id