github-actionsgit-checkoutsemantic-versioninggitversion

fetch-depth: 0 on github actions checkout is not fetching all tags and refs


I have a repo which has a TAG 1.0.0 on main and i am running a github workflow on branch "dev"

 steps:      
      - name: "Checkout Application repo"
        uses: actions/checkout@v3
        with:
          repository: ${{ inputs.repo_name }}
          token: ${{ secrets.token }}
          fetch-depth: 0
      - name: Gitversion
        id:  git-version
        run: |
          cd ${{github.workspace}}         
          $GitVersion = dotnet-gitversion /output json |ConvertFrom-Json
          echo $GitVersion.SemVer
        

I expect the semver to be 1.1.0 using Continous delivery mode , however the Semever is 1.0.1 and i tried to list git branch -l to see all branches listed , but i only see dev branch there with fetch-depth : 0 it should have all branch and tag information

what am i am missing here?


Solution

  • I know this is a bit late but I'm just going to add this answer because this question is the closest to what I was going through and maybe someone else will be saved from googling a whole day.

    I was facing exactly the same issue as you. I was trying to use GitVersion in a GitHub action. I had added a tag with a version number and everything worked locally, but on the build server It looked like git was not fetching tags. I had push all changed and as far as I could see the remote git repo was identical to my local repo. After a day of trying to get the build to work and venturing into different rabbit holes I finally, cloned the reop locally in a different folder and behold, no tag!

    So one google search later

    git push --tags
    

    And now GitVersion works in the GitHub action.