codacy / git-version

Git versioning used in Codacy
Apache License 2.0
134 stars 44 forks source link

[TS-653] Version does not consider base branch #92

Open jsmith-kno2 opened 1 year ago

jsmith-kno2 commented 1 year ago

I have the following branching strategy:

master -> rc -> feature branch master -> hotfix

Nothing remarkable; master represents what's in prod. We work in sprints, so the rc branch represents the accumulated sprint work. Occasionally we have an issue in prod that requires immediate resolution. In those cases, we branch from master to develop the hotfix. After the hotfix is merged into master, we need to merge those changes forward into rc.

I'm encountering an issue with the generated version when performing this merge forward from master to rc. I expected the version to be a pre-release as the base is not the default branch but instead it's generating a full release version because the current branch is the default branch.

Any suggestions or is this something that should possibly be considered in the version generation code?

github-actions[bot] commented 1 year ago

Internal ticket created : TS-653

jsmith-kno2 commented 1 year ago

In the off chance someone else comes across this problem and needs an immediate solution, this is how I've created a workaround:

        id: override
        run: |
          if [[ "$GITHUB_BASE_REF" == "rc" && "$GITHUB_HEAD_REF" == "master" ]]; then
            echo "release_branch=something_other_than_master_to_force_prerelease_version_generation" >> $GITHUB_ENV
          else
            echo "release_branch=master" >> $GITHUB_ENV
          fi
      - name: Generate new version
        id: version
        uses: codacy/git-version@2.8.0
        with:
          release-branch: ${{ steps.override.outputs.release_branch}}