Skip to content

git fetch on tag builds does not fetch the tag that initiated the build #25159

Answered by asbjornu
asbjornu asked this question in Actions
Discussion options

You must be logged in to vote

I ended up just using the git tag directly and disable GitVersion when the build is triggered from a tag with if: startsWith(github.ref, ‘refs/tags/’) != true. I perform the stable/unstable versioning logic with actions/github-script as follows:

const gemVersion = (function() {
  const ref = '${{ github.ref }}';
  const tagPrefix = 'refs/tags/';

if (ref.startsWith(tagPrefix)) {
// If a tag ref is being built, just return the tag verbatim
return ref.substring(tagPrefix.length);
}

const escapedBranchName = '${{ steps.gitversion.outputs.escapedBranchName }}';
const commitsSinceVersionSource = '${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}';
const preReleaseLabel = escapedBr…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants