BreadMoirai / github-release-gradle-plugin

A Gradle Plugin to send Releases to Github
Apache License 2.0
108 stars 26 forks source link

githubRelease stopped working with 2.3.7 #44

Open mduft opened 2 years ago

mduft commented 2 years ago

We were on 2.2.12 for a long while now, creating our releases just fine (thanks for that). However updating to 2.3.7 made it stop working completely. I reverted the update back to 2.2.12 which immediately returned it to working state.

We create the release from the current master branch, i.e. no pre-existing tag, github should create one on the fly.

With 2.2.12 we get this output:

20:54:56  > Task :test-data:githubRelease
20:54:56  :githubRelease CHECKING FOR PREVIOUS RELEASE
20:54:56  :githubRelease CREATING NEW RELEASE 
20:54:56  {
20:54:56      tag_name         = v4.3.0
20:54:56      target_commitish = master
20:54:56      name             = Release 4.3.0
20:54:56      body             = 
20:54:56          
20:54:56      draft            = false
20:54:56      prerelease       = false
20:54:56  }
20:54:56  :githubRelease STATUS 
20:54:56  :githubRelease https://github.com/bdeployteam/bdeploy/releases/tag/v4.3.0
20:54:56  :githubRelease UPLOADING ASSETS
20:54:56  :githubRelease UPLOADING /home/jenkins/agent/workspace/deployment/release/deployment/minion/build/distributions/bdeploy-linux64-4.3.0.zip
20:55:08  :githubRelease UPLOADING /home/jenkins/agent/workspace/deployment/release/deployment/minion/build/distributions/bdeploy-win64-4.3.0.zip
20:55:20  :githubRelease UPLOADING /home/jenkins/agent/workspace/deployment/release/deployment/api/build/libs/bdeploy-api-4.3.0.jar

With 2.3.7, we get:

19:37:01  > Task :test-data:githubRelease FAILED
19:37:01  :githubRelease CHECKING FOR PREVIOUS RELEASE
19:37:01  :githubRelease CREATING NEW RELEASE 
19:37:01  {
19:37:01      tag_name         = v4.3.0
19:37:01      target_commitish = main
19:37:01      name             = Release 4.3.0
19:37:01      body             = 
19:37:01          
19:37:01      draft            = false
19:37:01      prerelease       = false
19:37:01  }
19:37:01  
19:37:01  FAILURE: Build failed with an exception.
19:37:01  
19:37:01  * What went wrong:
19:37:01  Execution failed for task ':test-data:githubRelease'.
19:37:01  > Could not create release: 422 
19:37:01    [message:Validation Failed, errors:[[resource:Release, code:custom, field:tag_name, message:tag_name is not a valid tag], [resource:Release, code:custom, message:Published releases must have a valid tag], [resource:Release, code:invalid, field:target_commitish]], documentation_url:https://docs.github.com/rest/reference/repos#create-a-release]
19:37:01  

The according build.gradle looks like this:

githubRelease {
    if(project.hasProperty('githubToken')) {
        token project.getProperty('githubToken')
    }
    owner 'bdeployteam'
    repo 'bdeploy'
    tagName "v${version}"
    releaseName "Release ${version}"

    releaseAssets.from(project(":minion").linux64DistZip)
    releaseAssets.from(project(":minion").win64DistZip)
    releaseAssets.from(project(":api").shadowJar)
    [...]

    // increase read and write timeouts as the files are rather large :)
    client new OkHttpClient.Builder().readTimeout(10, TimeUnit.MINUTES).writeTimeout(10, TimeUnit.MINUTES).build();
}

We are "good" meanwhile with the downgrade, as we don't miss anything, however it would be nice to follow along with the releases :) Maybe we're doing something that is no longer supported?

BreadMoirai commented 2 years ago

Not sure if you've accounted for this but the default targetCommitish has been changed to 'main' to reflect new standards on Github but that doesn't seem related to your problem.

Only way I've been able to reproduce this is if I add whitespace to the end of the tagName. Perhaps there's a random space in the version at the end?

Jamalam360 commented 2 years ago

I'd just like to say I'm facing this exact error as well:

[message:Validation Failed, errors:[[resource:Release, code:custom, field:tag_name, message:tag_name is not a valid tag], [resource:Release, code:custom, message:Published releases must have a valid tag], [resource:Release, code:invalid, field:target_commitish]], documentation_url:https://docs.github.com/rest/reference/repos#create-a-release]

https://github.com/JamCoreModding/Gronk/tree/main/publishing.gradle.kts

:githubRelease CHECKING FOR PREVIOUS RELEASE
:githubRelease CREATING NEW RELEASE 
{
    tag_name         = 2.0.1
    target_commitish = main
    name             = V2.0.1 [1.16.x - 1.18.x]
    body             = 
        ## Changelog

                ### Features

                - Add a test case for `Config.requireHoe`.
                - Automate testing via GitHub Actions.

                ## Fixes

                - Fix a bug in `Config.requireHoe` where hoe durability did not decrease.

    draft            = false
    prerelease       = false
}
Jamalam360 commented 2 years ago

My issue was actually something else, I forgot I renamed branches from main to 1.16-1.18

mduft commented 2 years ago

Not sure if you've accounted for this but the default targetCommitish has been changed to 'main' to reflect new standards on Github but that doesn't seem related to your problem.

Finally another release day :) I was able to fix this by settings targetCommitish to master in the gradle task indeed. This was the issue. This might be worth some kind of hint/warning? I assume that 100% of repositories which already existed before the default changed will still have a master branch?