github-action-get-previous-tag
github-action-get-previous-tag copied to clipboard
Action pulls tag associated with latest commit, not the latest tag
(Sorry, the workflow is not accessible publicly)
Two tags of interest, 1.10.109 and 1.10.110. Pulling the timestamps for the associated commits:
The timestamps for the tags themselves:
Clearly, 1.10.110 was created at a later time than 1.10.109. However, this is what get-previous-tag returns:
Interestingly, the timestamp "1662046975" corresponds to the commit time shown in the first image:
In the code:
"rev-list" "lists commit objects in reverse chronological order" (per the git-rev-list manpage). So the revision that is being returned isn't the revision associated with the latest tag, it's the revision representing the latest commit.
A more accurate command to actually return the lastest tag might be:
git for-each-ref --sort=-taggerdate --format="%(refname:short) | %(taggerdate)" "refs/tags/*"
where the last returned value is, in fact, the latest tag:
(Sorry, the workflow is not accessible publicly)
No worries, it's normally useful for easier debugging. But you've made an outstanding case with examples all the way down. The code changes in the PR look good, but for some reason don't output a commit. Will see how they can be updated to fail when that is missing.