github-tag-action icon indicating copy to clipboard operation
github-tag-action copied to clipboard

If there is no tag on a repo, the script won't generate any tags or Changelog.

Open fcarrascosa opened this issue 3 years ago • 11 comments

After a lot of trying and error, I found an issue (maybe it's not a bug but a feature) when pushing code to a repository without tags. The parser will say there are no new commits, so it won't generate any new versions.

fcarrascosa avatar Feb 16 '21 03:02 fcarrascosa

I've gotten 0.0.1 on repos with no tags using v5 of this action

onwsk8r avatar Feb 16 '21 19:02 onwsk8r

I've encountered this as well, i started creating v0.0.0 releases every time i create a new repo

chrisjohnson00 avatar Feb 19 '21 22:02 chrisjohnson00

I've encountered this as well, i started creating v0.0.0 releases every time i create a new repo

That's exactly what I ended up doing...

fcarrascosa avatar Feb 20 '21 12:02 fcarrascosa

Hey @mathieudutour would you mind if I take this and make a PR for it during this week?

fcarrascosa avatar Feb 23 '21 12:02 fcarrascosa

yeah I'd be more than happy to review a PR :)

mathieudutour avatar Feb 23 '21 12:02 mathieudutour

I started working on this and I could isolate the case where this is happenning: default_bump set to 'false', it should probably create tag v0.0.0 or the correspoding semver tag for the commits.

fcarrascosa avatar Feb 27 '21 21:02 fcarrascosa

So, here's my question for you @mathieudutour, should the script automatically create the tag 0.0.0 or a tag based on the commits the user just pushed?

fcarrascosa avatar Feb 27 '21 22:02 fcarrascosa

Not sure I understand exactly but I'd say the script should assume the previous tag was 0.0.0 if there wasn't any before, and generate the real one based on the commits (and bump relatively to 0.0.0).

mathieudutour avatar Feb 27 '21 22:02 mathieudutour

Yup, you understood perfectly :) Ok! Will work on that

fcarrascosa avatar Feb 27 '21 22:02 fcarrascosa

So, this action already assumed the prior tag to be 0.0.0 when there is no tag in the repo. I have a no-code fix for this that I've implemented on some private repos:

I'd like the initial release for the repo to be v1.0.0 so I've set this up to calculate the default_bump in a prior step based on if there's a tag or not. The actions-ecosystem/action-get-latest-tag action defaults to v0.0.0 when there is no tag, so based on this I'm setting the default_bump to be major. If you want it to be 0.1.0, just set it to minor.

If you choose to set default_bump to false, then clearly this won't work.

    steps:
      - uses: 'actions/[email protected]'
        with:
          fetch-depth: 0
      - name: 'Action Get Latest Tag'
        uses: 'actions-ecosystem/[email protected]'
        id: 'get-latest-tag'
        with:
          semver_only: true
      - name: 'Determine default bump'
        id: 'bump'
        run: |
          LATEST_TAG=${{ steps.get-latest-tag.outputs.tag }}
          if [ "$LATEST_TAG" = "v0.0.0" ]; then
              echo "::set-output name=type::major"
          else
              echo "::set-output name=type::patch"
          fi
      - name: 'Bump version and push tag'
        id: 'tag_version'
        uses: 'mathieudutour/[email protected]'
        with:
          github_token: '${{ secrets.REPO_ONLY }}'
          release_branches: 'main'
          default_bump: '${{ steps.bump.outputs.type }}'

chrisjohnson00 avatar Jun 21 '21 23:06 chrisjohnson00

Is there an updated for this issue?

TurtleTT avatar Jan 18 '22 16:01 TurtleTT