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

Can't quite get auto-changelog right in github release notes. githubRelease runs before git commit/tag #1098

Closed
laduke opened this issue Apr 19, 2024 · 8 comments

Comments

@laduke
Copy link

laduke commented Apr 19, 2024

I think the issue is that github.releaseNotes runs before the new tag is created. I can't find an auto-changelog set up to make this work.

Say you have v0.6.6 and release-it is bumping to v0.6.7

In --ci, If you run like:

npx auto-changelog --stdout --starting-version=v0.6.6 --ending-version=0.6.7

or --ending-version=main

In your github.releaseNotes script, you will not get the 0.6.7 notes. You get v0.6.6 again. The v0.6.7 tag hasn't been created yet.

If you use the auto-changelog option: -p, --package [file] :

npx auto-changelog -p --stdout --starting-version=v0.6.6 

The stdout includes v0.6.6 and v0.6.7. There are two versions included in the release notes. The current and the previous.

npx auto-changelog -p --stdout --starting-version=v0.6.7

auto-changelog throw TypeError: Invalid version. Must be a string. Got type "undefined".

Would it break a bunch of existing users if githubRelease ran after the tag is created?

The only workaround I found so far is to run release-it twice. First with no githubRelase and second with --no-git.

I used literal values above. My releaseNotes script is some variation of:

npx auto-changelog -p --commit-limit=false --stdout --starting-version=${latestTag} --ending-version=${tagName}

npx release-it -VV --ci --dry-run

🚀 Let's release ballpit (0.6.6...0.6.7)
Changelog:
* adsf (228d793)
* one step (8e21f23)
* two steps (08a1f12)
* Release 0.6.8 (04c3dbc)
* docs: give up again (e093945)
* modified:   .release-it.json (5b0f56f)
* modified:   package.json (9ee7a4b)
* asdf (8e9006e)
* feat: bbb 5 (44a436d)
* feat: bbb 4 (5ed8835)
* feat: bbb 3 (ec87851)
* feat: bbb 2 (77555eb)
* feat: bbb 1 (1c74ce3)
! npm version 0.6.7 --no-git-tag-version
! npx auto-changelog -p --commit-limit=false
$ git status --short --untracked-files=no
Empty changeset
! git add . --update
! npx auto-changelog -p --commit-limit=false --stdout --starting-version=v0.6.6 --ending-version=v0.6.7
Empty release notes
! git commit --message Release 0.6.7
! git tag --annotate --message Release 0.6.7 v0.6.7
$ git symbolic-ref HEAD  [cached]
$ git for-each-ref --format="%(upstream:short)" refs/heads/main  [cached]
! git push --follow-tags
🔗 https://github.com/laduke/ballpit/releases/new?tag=v0.6.7&title=Release+0.6.7&body=npx+auto-changelog+-p+--commit-limit%3Dfalse+--stdout+--starting-version%3D%24%7BlatestTag%7D+--ending-version%3D%24%7BtagName%7D&prerelease=false
🏁 Done (in 0s.)

Actually I guess here it's completely empty because the commit to package.jason hasn't been done yet either.

oh here's the config too:

{
  "npm": {
    "publish": false
  },
  "github": {
    "release": true,
    "assets": ["build_artifact.txt"],
    "releaseNotes": "npx auto-changelog -p --commit-limit=false --stdout --starting-version=${latestTag}"
  },
  "hooks": {
    "after:bump": "npx auto-changelog -p --commit-limit=false"
  }
}
@laduke
Copy link
Author

laduke commented Apr 19, 2024

current workaround is something like

      - name: 'Bump Version'
        run: npx release-it --ci -VV --no-github.release $version

      - name: 'Create Release'
        run: npx release-it --ci -VV --no-increment --no-git

@webpro
Copy link
Collaborator

webpro commented Apr 19, 2024

You could also look into using releaseNotes as a function:

https://github.com/release-it/release-it/blob/main/docs/github-releases.md#release-notes

@webpro
Copy link
Collaborator

webpro commented Apr 19, 2024

Use the verbose or debug options to see the order of things and more details: https://github.com/release-it/release-it?tab=readme-ov-file#troubleshooting--debugging

@laduke
Copy link
Author

laduke commented Apr 19, 2024

Thanks for replying. I did use -VV to figure out what I think was happening.

I don't think auto-changelog is able to create the notes they right way until the tag/commit is there. I think I tried every combination.

I guess a function could possibly chop out the previous release notes if I run auto-changelog with the options that cause double release notes.

@webpro
Copy link
Collaborator

webpro commented Apr 19, 2024

I've been using auto-changelog, but it's a while ago. Usually these tools work based on the commits since a certain tag. Also note that in dry mode the ! mean that the command didn't actually run (user commands could be writing something).

@laduke
Copy link
Author

laduke commented Apr 19, 2024

Also, this arguably is an auto-changelog issue/request.

I'm also not stuck on auto-changelog. I could just try conventional or keepachangelog

Or just put the git log into the githubRelease...

@webpro
Copy link
Collaborator

webpro commented Apr 19, 2024

With any tool, also make sure to verify things by simply running the commands in sequence manually.

@webpro
Copy link
Collaborator

webpro commented May 8, 2024

Closing this one, but feel free to continue discussion or open new ones.

@webpro webpro closed this as completed May 8, 2024
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