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
    types: [created]
    runs-on: ubuntu-latest
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v1
          java-version: 1.8
      - name: Publish package
        run: gradle publish
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

here’s the publishing section from build.gradle

publishing {
    repositories {
        maven {
            name = "GitHubPackages"
            url = ""
            credentials {
                username = System.getenv("GITHUB_ACTOR")
                password = System.getenv("GITHUB_TOKEN")

and the build output:-

 Publish package32s
Run gradle publish
  gradle publish
  shell: /bin/bash -e {0}
    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

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

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.


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("")
            credentials {
                username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
                password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
    publications {
        gpr(MavenPublication) {

Here is sample repro from github staff:


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