ncipollo / release-action

An action which manages a github release

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Regression: Published release became draft after update

constgen opened this issue · comments

Describe the bug
This issue is back again #185

To Reproduce
The repository is not public.
This is the log of the step from the GitHub Actions:

Run ncipollo/release-action@v1
  with:
    tag: 99
    commit: e531cfa28be3e92983a87187bc131a24367297af
    allowUpdates: true
    removeArtifacts: true
    name: 99
    body: ## Actions ....
    generateReleaseNotes: true
    prerelease: false
    draft: false
    omitDraftDuringUpdate: true
    makeLatest: legacy
    omitBody: false
    omitBodyDuringUpdate: false
    omitName: false
    omitNameDuringUpdate: false
    omitPrereleaseDuringUpdate: false
    replacesArtifacts: true
    skipIfReleaseExists: false
    token: ***
    updateOnlyUnreleased: false

On the second run the release becomes draft. The body is updated correctly but without generated release notes. They disappear (probably because of draft)

Expected behavior
If it is run twice everything may be updated besides draft

I just testing this in my test repo and it's working fine for me: https://github.com/ncipollo/actions-playground/blob/master/.github/workflows/tag.yml#L37

I'm not sure how this could be setting your release as a draft, your draft property is set to false... so even without omitDraftDuringUpdate I would not expect it to mark your repo as a draft. As you sure something else isn't going on in your repo?

I went through a whole sequence of draft, normal release, back to draft, etc and this flag seemed to work each time: https://github.com/ncipollo/actions-playground/actions

A couple of things for you to check in your private repo:

  • Look at the action logs, it will print out the inputs. You verify that the inputs are as you would expect.
  • Your body input looks like it contains the markdown for the release notes. You should probably make sure that is properly escaped, etc.
  • Make sure there aren't other actions running which might be settings this release to be a draft.
  • In the issue description there is an input that I copied from the logs.
  • There are definitely no other actions running

You may try one more case. Add the step to delete the latest tag before running this action. But run it with the same tag name every time. For example just hardcode the tagname to 1.0 and run the steps twice. This action should re-create the tag on a new commithash. And this what could cause the issue

If that's the case this might be a behavior of GitHub. When you have omit draft set to true we don't pass that up, so whatever is the default behavior of GitHub for drafts would be happening here.

We've been having the same issue. After reading your comments here I've tried to use draft and omitDraftDuringUpdate to force the draft state to be set to false during the update, no luck unfortunately. Here's the output (look for "Nightly Release" at https://github.com/coreruleset/coreruleset/actions):

Run ncipollo/release-action@v1
  with:
    name: Latest Nightly
    tag: nightly
    commit: v[4](https://github.com/coreruleset/coreruleset/actions/runs/4559973892/jobs/8044470367#step:4:4).0/dev
    allowUpdates: true
    prerelease: true
    draft: false
    omitDraftDuringUpdate: false
    token: ***
    body: Nightly releases are snapshots of the development activity on the Core Rule Set project that may include new features and bug fixes scheduled for upcoming releases. These releases are made available to make it easier for users to test their existing configurations against the Core Rule Set code base for potential issues or to experiment with new features, with a chance to provide feedback on ways to improve the changes before being released.
  
  As these releases are snapshots of the latest code, you may encounter an issue compared to the latest stable release so users are encouraged to run nightly releases in a non production environment. If you encounter an issue, please check our issue tracker to see if the issue has already been reported; if a report hasn't been made, please report it so we can review the issue and make any needed fixes.
  
  **Note:** Nightly releases using release action are only available via GitHub.
  
    generateReleaseNotes: false
    makeLatest: legacy
    omitBody: false
    omitBodyDuringUpdate: false
    omitName: false
    omitNameDuringUpdate: false
    omitPrereleaseDuringUpdate: false
    removeArtifacts: false
    replacesArtifacts: true
    skipIfReleaseExists: false
    updateOnlyUnreleased: false

@ncipollo I can open a new issue if you like. Or do you think there's no way for you to make this work with an action anyway?

I don't think this is something the action can resolve, unless you can figure out some combination of settings to provide to the GitHub api to prevent it from marking the release as a draft in this case.

Generally, GitHub releases work best when you have a tag already and create a release from that. You can probably simplify your workflow by having a step before the release action which creates and pushes the tag.

Thans for getting back to me so quickly! I'll try some stuff. If I figure it out I'll report it here for posterity.

After your hint @ncipollo I looked at the GitHub API and discovered that updating tags is just not supported. Knowing that, I updated our workflow and the nightly build has been working perfectly every since. The trick is to delete both the release and the tag before recreating it.

    steps:
      - name: "Checkout repo"
        uses: actions/checkout@v3

      - name: "Remove nightly tag before creating new release (ensures that tag is updated)"
        uses: dev-drprasad/delete-tag-and-release@v0.2.1
        with:
          delete_release: true
          tag_name: nightly
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Deploy using Release Action
        uses: ncipollo/release-action@v1
        with:
          name: Latest Nightly
          tag: nightly
          commit: v4.0/dev
          allowUpdates: true
          prerelease: true
          token: ${{ secrets.GITHUB_TOKEN }}
          body: lorem ipsum