quant-eagle / conventional-changelog-generator

Generate a changelog based on the conventional commit history for the latest tag.
8 stars 4 forks source link

Cannot read property 'commit' of undefined #1

Open Blueforcer opened 3 years ago

Blueforcer commented 3 years ago

Hello im very new to github actions and want to use your changelog generator. Unfortunally i get this error:

Run Helmisek/conventional-changelog-generator@v1.0.6-release
fetch all tags in repository...
fetched all 1 tags in repository.
sorted tags by semver.
showing up to 10 last tags...
tag 2021.1.18.2345
fetch all releases...
fetched all 1 releases.
current release index: -1
Error: TypeError: Cannot read property 'commit' of undefined

What does it means?

Thanks in advance

quant-eagle commented 3 years ago

Hello, thanks for reporting the issue.

Can you please post your configuration for this action too?

It seems that the action wasn't able to fetch any commits. And also the range is quite off as the current release index shouldn't be -1.

Blueforcer commented 3 years ago

sure,

      - name: Changelog generation step
        uses: Helmisek/conventional-changelog-generator@v1.0.6-release
        id: changelog-generator
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          commit-types: "fix:Bug Fixes,feat:Features,refactor:Refactoring"
          current-tag: ${{ env.PACKET_VERSION }}
      - name: Print version
        run: echo ${{ env.PACKET_VERSION }}
      - name: Print changelog
        run: echo "${{steps.changelog-generator.outputs.changelog}}"

im not sure about the "current-tag". right now im using a new tag wich is generated in the same workflow for release upload

quant-eagle commented 3 years ago

Thanks, the configuration itself seems fine.

Are you sure the newly generated tag is pushed before the action is called and you can see it in the log of the action?

Or if the env value provides a proper tag value? The ´current-tag´ field is used to select a proper tag from the list.

I was able to reproduce your issue by providing a non-existent tag to the ’current-tag´ field.

Anyway this is a good edge case to handle.

quant-eagle commented 3 years ago

Alternatively, you could just remove the ´current-tag´ field.

This would tell the action to use the first tag available. That should be the same as the first tag you get when calling ´git tag´ in terminal.

Blueforcer commented 3 years ago

ah ok. Now i understand. the tag doesnt exists at this time, because i want to have the fresh changelog file inside my release package. I think i need to rethink my workflow. Thanks for that hint

i tried to remove the tag.

Run Helmisek/conventional-changelog-generator@v1.0.6-release
fetch all tags in repository...
fetched all 1 tags in repository.
sorted tags by semver.
showing up to 10 last tags...
tag 2021.1.18.2345
fetch all releases...
fetched all 1 releases.
current release index: 0
current release sha: "e9b6e3be31f0082e1b03f38fa0fc56b19d125e34"
previous release index: -1
previous release sha: "0b2a0a019d5926cb19e74c195d55c0930725cf09"
fetch commit range...
requested commits between "0b2a0a019d5926cb19e74c195d55c0930725cf09" and "e9b6e3be31f0082e1b03f38fa0fc56b19d125e34" fetched. (99)
retrieveing changelog mapping
Error: Error: ENOENT: no such file or directory, open 'CHANGELOG.tpl.md'

does this error also belongs to my wrong workflow? Because I dont set a template

quant-eagle commented 3 years ago

OK, great we figured that out.

Unfortunately this is based on the API, so you have to have it pushed already.

I was also thinking of preparing an integration which would allow you to use this action which would work with the git history in the local repo.

It'd be a great enhancement for use cases like yours.

Also about the error you're getting, that's definitely the error on side of the action.

For me it works well without the path specified and it falls back to the default one. So I will have to investigate why this happened to you.

Thanks for reporting these! ✅

I am going to focus on handling these edge cases and errors for the next version so the integration is more seamless and more informative in the future.

Blueforcer commented 3 years ago

Thank you very much for your help! Have a nice day

quant-eagle commented 3 years ago

You are welcome. I will close this issue once the new release is out and fixes these problems.

You too have a nice day.

hobbsh commented 3 years ago

I am using this as a workaround for the changelog template not being found:

       - name: Dump changelog template
         run: |
           echo '###CHANGELOG' > CHANGELOG.tpl.md
           echo 'VERSION: {{versionName}} | Created: {{date}}' >> CHANGELOG.tpl.md
           echo '{{.SECTION}}### $title{{.SECTION}} {{.COMMITS}}- $commit{{.COMMITS}}' >> CHANGELOG.tpl.md