mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.52k stars 240 forks source link

Version bump happens after tagging #697

Open terlar opened 5 months ago

terlar commented 5 months ago

Describe the bug When building from source and using the tags the version will be wrong (the previous one). Since the commit bumping the version in the package.json happens after the tagging.

To Reproduce Steps to reproduce the behavior:

  1. Checkout any tag
  2. Build the mermaid CLI
  3. mmdc --version
  4. Notice the invalid version (the previous release)

Expected behavior The version should match the version of the tag.

MindaugasLaganeckas commented 4 months ago

Hi @terlar

Well spotted.

I think the easiest way to fix the issue is to re-tag the code during the release in the pipeline. Here is the code the sets the version in the package.json file: https://github.com/mermaid-js/mermaid-cli/blob/ee9fc8fe74a59a0a7a18507d4b69e0a5faf47a9e/.github/workflows/release-publish.yml#L101

Retagging after the file update would fix it. Or do you have another proposal?

Would you be interested in providing a fix to the problem?

terlar commented 4 months ago

I agree that re-tagging is the easiest solution. The downside is that it mutates the tag (although very briefly) and that we would have to figure out how to not then trigger the workflow again.

I guess the other option would be if there is another way to trigger a release and then do the tagging as part of the release. So if the trigger is a commit itself and then that will trigger the bumping, tagging and the release.

There is https://github.com/googleapis/release-please but perhaps that is too involved, too much of a change to the current process.

If we can come up with something I could assist in making it happen.

MindaugasLaganeckas commented 4 months ago

It is not a tag, that triggers a release in our workflow today. It is actually a published release event that triggers the pipeline. Creating/pushing a new tag should not start the workflow again. Link to the code code https://github.com/mermaid-js/mermaid-cli/blob/ee9fc8fe74a59a0a7a18507d4b69e0a5faf47a9e/.github/workflows/release-publish.yml#L5

When I create a new release, both creating a tag and publishing of the release (note) happens at the same time.

I hope that my input is not confusing :)