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

fatal: tag 'project-name-0.1.0' already exists #569

Open
gabsmprocha opened this issue Jul 18, 2022 · 17 comments
Open

fatal: tag 'project-name-0.1.0' already exists #569

gabsmprocha opened this issue Jul 18, 2022 · 17 comments

Comments

@gabsmprocha
Copy link

gabsmprocha commented Jul 18, 2022

Hi guys,

fatal: tag 'project-name-0.2.0' already exists
    at ChildProcess.exithandler (child_process.js:383:12)
    at ChildProcess.emit (events.js:[40](https://github.com/***
    check_suite_focus=true#step:5:41)0:28)
    at maybeClose (internal/child_process.js:1088:16)
    at Socket.<anonymous> (internal/child_process.js:446:11)
    at Socket.emit (events.js:400:28)
    at Pipe.<anonymous> (net.js:686:12)

this problem always happens in github actions, even though I do a git fetch --tags before

env:
   GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
    - uses: actions/checkout@v2
      with:
          fetch-depth: 0
          token: ${{ secrets.GH_API_TOKEN }}

    - name: Cache (node_modules)
      uses: ./.github/custom-actions/cache-node-modules
      with:
          cache-version: ${{env.CACHE_VERSION}}

    - name: Setup git user to "🤖 github-actions bot"
      shell: bash
      run: git config user.email "<>" && git config user.name "🤖 github-actions[bot]" && git fetch --tags

   - name: version
      run: nx affected --target=version --releseAs=minor
@gabsmprocha
Copy link
Author

@edbzn

@edbzn
Copy link
Member

edbzn commented Jul 19, 2022

@gabsmprocha this means that you already created a tag project-name-0.2.0 but the tag is not pointing to a main branch reference. You have to delete the tag, or re-tag the base branch.

@edbzn
Copy link
Member

edbzn commented Jul 19, 2022

You don't need to fetch the tags as fetch-depth: 0 already does the job.

@gabsmprocha
Copy link
Author

gabsmprocha commented Jul 19, 2022

but when i checkout using actions/checkout@v2 i can see the tag there, and semver does not find it, why?

@gabsmprocha
Copy link
Author

the problem with deleting the tags is that the release would not increment, because it would always end up going back to 0.1.0, I believe that if the tag already exists, shouldn't the plugin try to increment it?

@edbzn
Copy link
Member

edbzn commented Jul 19, 2022

because your tag does not point to the base branch that semver uses so it can't calculate the new version from it.

@gabsmprocha
Copy link
Author

And what is the base branch that semver uses?
I'm using NX_BASE=HEAD~1
E NX_HEAD=HEAD

because it is executed in a workflow after the merge in main

@edbzn
Copy link
Member

edbzn commented Jul 19, 2022

the default is main, your worklow runs on main as well?

@gabsmprocha
Copy link
Author

yes, running based on main, as the repository uses squash merge we make this base and head definition that I gave you above to have the output of affected projects

@gabsmprocha
Copy link
Author

the error happens even if I run locally

@edbzn
Copy link
Member

edbzn commented Jul 19, 2022

are you sure the tag project-name-0.2.0 points to a commit referenced in main?

@gabsmprocha
Copy link
Author

yes

@edbzn
Copy link
Member

edbzn commented Jul 19, 2022

Umh, that's hard to tell then, can I access the repo by any chance?

@gabsmprocha
Copy link
Author

gabsmprocha commented Jul 22, 2022

unfortunately not, because it's a private repository, I decided to go for a last-release milestone strategy, similar to what I could see you guys do, but I had another doubt, how can I include the dependencies changes on my changelog? can you help me understand this point? @edbzn

@rajput2107
Copy link

I'm facing this issue sometimes as well. The old tag exists in my "main" branch but sometime's it still says this tag exists. And for few it start's saying No Previous version found. But I've cross checked all the tags are still there in my main branch. We also merge branches after squashing incoming branch commits but it shouldn't create any issue because all the tag references are there in master.

@daton89
Copy link

daton89 commented Sep 30, 2022

I had the same issue and I noticed that merging the release PR with squash instead of merge commit was breaking the link between tag and the main branch, can this be the cause?

@mklueh
Copy link

mklueh commented Dec 19, 2023

I was stumbling into the same issue. I have the master branch and feature branches, and I release alpha versions on feature and normal versions on master.

When master is on 0.1.0 and FEATURE-1 does an alpha release, it will create 0.1.1-alpha.0

Now the problem will occur, when I don't merge this branch on master and open FEATURE-2.

it will also start from version tag 0.1.0 (from master) and will create tag 0.1.1-alpha.0 and then the error occurs, as git branches are valid across all branches.

I'm currently solving this by bringing the branch name into the --preid, so it will create 0.1.1-FEATURE-1-alpha.0

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

5 participants