Publishing GitHub Packages returns 422 error

I have been using GitHub packages for a while, in an Android project, without having any issue.
Now when I try to publish a new package I get the error:

Could not PUT Received status code 422 from server: Unprocessable Entity

To be sure that I hadn’t change anything I went back to a version that successfully managed to publish a version a few days ago, I changed only the tag to generate a different package. I get the same error.

I added logs and I can see that the token is read correctly, all the value (GROUP, VERSION, etc) seem correct and that the file that I’m trying to publish is there in the correct folder.
I have also tried to create and use a new token in case something was wrong with the old one but it didn’t help.

Would GitHub reject the publishing with that error in case I published too many files? I did not find any documentation about the error that you get in that case.

In this post I’ve found that now artifact-id must be all lower case. I tried that too but I’m still getting the same issue.
I have tried to PUT a file directly using CURL and it worked:

curl -X PUT \
"https://maven.pkg.github.com/companyname/repositoryname/com/companyname/artifactid/v2.1.520/artifactid-v2.1.520.aar" \
-H "Authorization: token mytoken” \
--upload-file “/full/path/to/file.aar" -vvv

Of course, this is not the solutions since I need to post the maven repo with the pom etc.

Here my configuration that had been working for a long time and that is just following the documentation + the logs that I added to investigate the issue.

In the build.gradle:

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            name = "GitHubPackages"
            url = uri("https://maven.pkg.github.com/companyname/companyname-android-sdk")
            credentials {
                username = project.findProperty("gpr.user") ?: System.getenv("GitHubPackagesUsername")
                password = project.findProperty("gpr.key") ?: System.getenv("GitHubPackagesToken")
                println "GitHubPackages build.gradle\n\tusername=$username\n\ttoken=$password"
            }
        }
    }
}

in a publish-artifacts.gradle:

publishing {
    repositories {
        maven {
            name = "GitHubPackages"
            url = uri("https://maven.pkg.github.com/companyname/companyname-android-sdk")
            credentials {
                username = project.findProperty("gpr.user") ?: System.getenv("GitHubPackagesUsername")
                password = project.findProperty("gpr.key") ?: System.getenv("GitHubPackagesToken")
                println "GitHubPackages Publish Artifact:\n\tusername=$username\n\ttoken=$password"
            }
        }
    }

    publications {
        gpr(MavenPublication) {
            println "\tskSdkVersion=$SK_SDK_VERSION\n\tarchivesBaseName=$archivesBaseName\n\tGROUP=$GROUP\n\tdesciption=$POM_DESCRIPTION"
            println "artifact from $buildDir/outputs/aar/$archivesBaseName-${VARIANT_SUFFIX}.aar"
            groupId SK_GROUP
            version SK_SDK_VERSION
            artifactId archivesBaseName
            artifact "$buildDir/outputs/aar/$archivesBaseName-${VARIANT_SUFFIX}.aar"
            description POM_DESCRIPTION
            pom.packaging POM_PACKAGING
            pom.withXml {
                def dependenciesNode = asNode().appendNode('dependencies')
                configurations.implementation.allDependencies.each {
                    println "dependency=$it"
                    def dependencyNode = dependenciesNode.appendNode('dependency')
                    dependencyNode.appendNode('groupId', it.group)
                    dependencyNode.appendNode('artifactId', it.name)
                    dependencyNode.appendNode('version', it.version)
                }
            }
        }
    }
}

in the gradle.properties file:

POM_NAME=PackageName
POM_PACKAGING=aar
GROUP=com.companyname
POM_DESCRIPTION=CompanyName SDK Core library

VARIANT_SUFFIX is set from an env variable.

archivesBaseName is set in the module’s build.gradle

artifactId should be lowercase to be able to publish to github packages.

Thank you @zd-dalibor. I have also tried to use lower case. It did not help