requarks / changelog-action

GitHub Action to generate changelog from conventional commits
MIT License
128 stars 41 forks source link

Provided tag doesn't match latest tag #14

Closed czernika closed 1 year ago

czernika commented 1 year ago

I'm facing issue that changelog contains changes for previous tag (1.0.6 - 1.0.7) not latest one (1.0.7 - unreleased draft 1.0.8)

This is my release list

Снимок экрана от 2022-12-29 12-17-22

Workflow steps

  - name: Checkout code
    uses: actions/checkout@v2

  - name: Get Next Semantic Version
    id: semver
    uses: ietf-tools/semver-action@v1
    with:
      token: ${{ secrets.GITHUB_TOKEN }}
      branch: master

  - name: Update CHANGELOG
    id: changelog
    uses: requarks/changelog-action@main
    with:
      token: ${{ secrets.GITHUB_TOKEN }}
      tag: ${{ steps.semver.outputs.current }}
      writeToFile: false

  - name: Create Release
    uses: ncipollo/release-action@v1
    with:
      allowUpdates: true
      draft: true
      name: ${{ steps.semver.outputs.next }}
      tag: ${{ steps.semver.outputs.next }}
      body: |
        ## What's Changed :eyes:

        ${{ steps.changelog.outputs.changes }}

        **Full Changelog**: https://github.com/czernika/tailwindcss-grid-area/compare//${{ steps.semver.outputs.current }}...${{ steps.semver.outputs.next }}
      token: ${{ secrets.GITHUB_TOKEN }}

Action passed however it is generates wrong changelist (1.0.6 - 1.0.7)

Снимок экрана от 2022-12-29 12-17-35

If I'll set next version as tag: v1.0.8 or use range fromTag: v1.0.7 toTag: v1.0.8 it fails

Снимок экрана от 2022-12-29 12-22-25

NGPixel commented 1 year ago

Your steps are in the wrong order. You're trying to generate the changelog for a tag that is only created in the next step.

You need to first create the next tag (e.g. via the release-action), then generate the changelog, then update the release with the changelog:

  - name: Checkout code
    uses: actions/checkout@v3

  - name: Get Next Semantic Version
    id: semver
    uses: ietf-tools/semver-action@v1
    with:
      token: ${{ secrets.GITHUB_TOKEN }}
      branch: master

  - name: Create Draft Release
    uses: ncipollo/release-action@v1.12.0
    with:
      prerelease: true
      draft: false
      commit: ${{ github.sha }}
      name: ${{ steps.semver.outputs.next }}
      tag: ${{ steps.semver.outputs.next }}
      body: '*pending*'

  - name: Update CHANGELOG
    id: changelog
    uses: requarks/changelog-action@v1
    with:
      token: ${{ secrets.GITHUB_TOKEN }}
      tag: ${{ steps.semver.outputs.next }}
      writeToFile: false

  - name: Update Release
    uses: ncipollo/release-action@v1.12.0
    with:
      allowUpdates: true
      draft: false
      name: ${{ steps.semver.outputs.next }}
      tag: ${{ steps.semver.outputs.next }}
      body: |
        ## What's Changed :eyes:

        ${{ steps.changelog.outputs.changes }}

        **Full Changelog**: https://github.com/czernika/tailwindcss-grid-area/compare//${{ steps.semver.outputs.current }}...${{ steps.semver.outputs.next }}
      token: ${{ secrets.GITHUB_TOKEN }}
czernika commented 1 year ago

@NGPixel thanks it works

However I need a draft to be created so I have now other issues but they're not related to this one so I will not bother. I guess I'll need to change my workflow. At least I understood what's caused issue with the latest tag) Thanks again!

jeacott1 commented 1 year ago

@NGPixel I ran into this today, but I would argue that my steps are not in the wrong order. I want to bump my version and commit my changelog in a single commit, not require multiple commits. how can I do this when this actions wont allow it?

NGPixel commented 1 year ago

@jeacott1 This issue has nothing to do with multiple commits... What are you trying to do?

jeacott1 commented 1 year ago

@NGPixel perhaps I misunderstood your previous answer "You're trying to generate the changelog for a tag that is only created in the next step."

my process is this. on PR merge->main I want to bump the version and generate a changelog. I want to commit those changes and tag that commit with the version #. - this works fine except when I'm trying to use this action I'm getting this "Provided tag doesn't match latest tag" error. it should be noted that I'm triggering on pr closed, not tag here, and I'm using a simple

        uses: requarks/changelog-action@v1
        with:
          tag: ${{ github.ref_name }}

where ${{ github.ref_name }} is 'main' in this case.