Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft update clears the release notes body #474

Closed
rantoniuk opened this issue Oct 29, 2024 · 5 comments
Closed

Draft update clears the release notes body #474

rantoniuk opened this issue Oct 29, 2024 · 5 comments

Comments

@rantoniuk
Copy link

I'm creating a workflow that creates/updates a draft release on every push to the dev branch. In other words, every time a PR is merged to dev (without a tag yet created:

  • if the draft release does not exist, create it and generate release notes - this works fine
  • if the draft already exists, update the body by overwriting it to reflect new commits added.
    THis part doesn't work, the draft release gets updated but the body of release notes gets cleared and is empty.

If the draft release is deleted manually and the workflow is re-run, then it again creates properly the draft.

The workflow:

name: Release Drafter

on:
  push:
    branches:
      - dev

permissions:
  contents: write # This is required for pushing new release

jobs:
  release:
    runs-on: ubuntu-latest

    steps:

      - name: "Github Actions Auth"
        id: ghactions-auth
        uses: actions/create-github-app-token@v1
        with:
          app-id: ${{ vars.GHACTIONS_PAT_APP_ID }}
          private-key: ${{ secrets.GHACTIONS_PAT_APP_ID_PK }}
          owner: ${{ github.repository_owner }}

      - uses: actions/checkout@v4
        with:
          token: ${{ steps.ghactions-auth.outputs.token }}
          fetch-depth: 0

      - name: Python Semantic Release
        uses: python-semantic-release/[email protected]
        id: semantic-release
        with:
          github_token: ${{ steps.ghactions-auth.outputs.token }}
          root_options: "-c .semantic-release.toml"
          push: "false"
          changelog: "false"
          vcs_release: "false"
      
      - name: Draft the next GitHub release 
        uses: ncipollo/release-action@v1
        with:
          token: ${{ steps.ghactions-auth.outputs.token }}
          tag: ${{ steps.semantic-release.outputs.tag }}
          commit: "dev"
          removeArtifacts: true
          generateReleaseNotes: true
          draft: true
          allowUpdates: true
          updateOnlyUnreleased: true

As you see, the future tag is generated by the [email protected] action.
Then, the release-action kicks in and correctly creates 1.0.0 release on the first run (when it does not exist) and the release notes are correctly generated.

However, on a re-run of the same workflow, it updates the draft release and clears the release notes, they are just empty. If I delete the draft and re-run again, then again the body is correctly generated.

@ncipollo
Copy link
Owner

The release notes generation is totally managed by GitHub, I'm just calling through to their API. It usually tries to diff from the last version so I'm guessing it's seeing your existing release and not seeing any change set. In any case nothing to really change in the action. Your best bet would be to manually create your release notes and attach them.

@ncipollo ncipollo closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2024
@rantoniuk
Copy link
Author

@ncipollo well, no, that's not a proper resolution to the problem, but I understand you saying this is not generated on your side. It is still a bug though, maybe on the GH octokit side.
From your description then, I'm guessing that it shouldn't see draft releases, i.e. they should not impact release notes generation.

FWIW, if #440 gets implemented, then this can be a workaround.

@ncipollo
Copy link
Owner

Yeah - not really sure completely. The generate release notes is kind of a black box. If #440 would resolve this issue for you please feel free to drop your usecase in there so I can consider it when I get around to taking a look at that guy.

@rantoniuk
Copy link
Author

The release notes generation is totally managed by GitHub, I'm just calling through to their API. It usually tries to diff from the last version so I'm guessing it's seeing your existing release and not seeing any change set. In any case nothing to really change in the action. Your best bet would be to manually create your release notes and attach them.

Actually, I looked at it again and I'm not so sure, because if that would be the case, the same would happen in the UI. So I went ahead to one of my repos in the GH UI in the browser:

  • I created a draft release, named a new (non-existing) tag and previous (existing) that to generate release notes - all worked fine, I saved the draft release
  • then I tried to create another draft release, with exactly the same settings - and it again all worked fine

Can you point me to the relevant lines in your source code to try to replicate this behavior with curl GH API before I report a bug to them?

@rantoniuk
Copy link
Author

rantoniuk commented Nov 7, 2024

For anyone ending up here, the workaround for this bug is currently to delete the release. This should be though reopened imo and either resolved internally (delete the draft before updating it) or upstream (finding the root cause).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants