Skip to content

--notes-from-tag should warn if the tag is not annotated #9558

Open

Description

@martinbonnin

From https://cli.github.com/manual/gh_release_create:

 --notes-from-tag 
    Automatically generate notes from annotated tag

My experience has been that --notes-from-tag uses the commit message of the commit associated with the tag. This is misleading as "annotated tag" has a specific meaning in git (cf https://git-scm.com/book/en/v2/Git-Basics-Tagging) so I would have expected the notes to be taken from the tag message, not the commit.

Can --notes-from-tag use the annotated tag message instead?

See also #8372

Activity

  1. added
    bug
    on Sep 2, 2024
  2. added
    needs-triage
    on Sep 2, 2024
  3. added
    enhancement
    gh-release
    and removed
    bug
    on Sep 3, 2024
  4. Goooler commented on Sep 3, 2024

    @Goooler
    Contributor

    Seems there are various bugs on different devices,

    • The tag refed commit title is treated as the release notes on Linux but Mac.
    • The first line of the tag message has been amended to the release title when there is no explicit --title option passed.

    You can repro and view all these cases at Goooler/keep-a-changelog#1.

  5. Goooler commented on Sep 3, 2024

    @Goooler
    Contributor

    I would prefer --notes-file over --notes-from-tag, guys who have been blocked by issues related to this could try the workaround like https://github.com/GradleUp/shadow/blob/ae72788e9475da71cb3874239723eb91839f9ba5/.github/workflows/release.yml#L40-L49

  6. martinbonnin commented on Sep 3, 2024

    @martinbonnin
    Author

    --notes-file or just plain --notes work for me. It's a tiny bit more work but largely doable.

    --notes-from-tag as it stands is pretty much misleading. I would vote to either fix it (by using the tag message) or just remove it.

  7. spenserblack commented on Sep 3, 2024

    @spenserblack
    Contributor

    What's the output for

    git tag --list TAG_NAME --format='%(contents)'

    and is that the expected release notes?

  8. martinbonnin commented on Sep 3, 2024

    @martinbonnin
    Author

    Using https://github.com/GradleUp/gratatouille/tree/v0.0.3:

    $ git tag --list v0.0.3 --format='%(contents)'
    * Added `com.gradleup.gratatouille` for `buildSrc` and other use cases where classloader isolation isn't required.
    * Expose the normalized path in `GInputFiles`
    

    This is the expected changelog.

    But when creating the release from CI (here), the release notes are the contents of the commit:

    Screenshot 2024-09-04 at 00 02 27

    What am I missing?

  9. spenserblack commented on Sep 3, 2024

    @spenserblack
    Contributor

    Might want to check the behavior of actions/checkout, actually. I remember a while ago I was having issues with actions/checkout not including my tags in the checkout, and I ended up doing this:

    - uses: actions/checkout@<commit-ish>
      with:
        ref: ${{ github.ref }}
  10. spenserblack commented on Sep 3, 2024

    @spenserblack
    Contributor

    I just played around with this. actions/checkout does this command: git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +ff7e2f589fe52277099dddff1fc2a5400105b47d:refs/tags/v0.0.4. Note the --no-tags flag. I ran this locally, and it did clone the tag, but it was not annotated. I ran git tag --list TAG_NAME --format='%(contents)' and it returned the commit message. It's strange behavior, but it looks like explicitly fetching the tag and passing --no-tags causes the tag to be fetched without annotations. I can't say I've experimented enough to know this for sure, but I'm pretty confident. But I did then call git tag -d v0.0.4; git fetch to force the tag to be re-fetched. Then I called git tag --list TAG_NAME --format='%(contents)' again, and it did print the tag's annotated message.

    So I think what the CLI is missing, if anything, is a way to report that the tag it's referencing is not annotated, and it's using the commit message instead. But with a "normal" clone, it should work as expected.

  11. Goooler commented on Sep 4, 2024

    @Goooler
  12. martinbonnin commented on Sep 4, 2024

    @martinbonnin
    Author

    Thanks @spenserblack, this is it indeed. Your workaround works for me:

    - uses: actions/checkout@<commit-ish>
      with:
        ref: ${{ github.ref }}

    FWIW, there's some discussion and people with the same issue in actions/checkout#1467.

    So I think what the CLI is missing, if anything, is a way to report that the tag it's referencing is not annotated, and it's using the commit message instead.

    +1. That would be very welcome.

  13. Goooler commented on Sep 4, 2024

    @Goooler
    Contributor

    This workaround works for me. The new issue should be

    The first line of the tag message has been appended to the release title when there is no explicit --title option passed.

    See https://github.com/Goooler/keep-a-changelog/releases/tag/v1.1.7

  14. changed the title [-]`--notes-from-tag` uses commit message instead of tag message[/-] [+]`--notes-from-tag` should warn if the tag is not annotated[/+] on Sep 4, 2024
  15. martinbonnin commented on Sep 4, 2024

    @martinbonnin
    Author

    The first line of the tag message has been amended to the release title when there is no explicit --title option passed.

    @Goooler what would you like the title to be instead? The name of the tag? Something else?

    I've updated the title of this issue to be about warning if the tag is not annotated. Can you add a separate one for the title?

  16. Goooler commented on Sep 4, 2024

    @Goooler
    Contributor

    I filed a new one to #9563.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgh-releaseneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions