Why does GitHub not get the pushed tag as annotated?
Locally if I run this command:
git for-each-ref
--format="%(if:equals=tag)%(objecttype)%(then)a %(else)%(if:equals=blob)%(objecttype)%(then)b %(else) %(end)%(end)%(align:20,right)%(refname:short)%09%(objectname:short)%(end)%09%(if:equals=tag)%(objecttype)%(then)@%(object) %(contents:subject)%(else)%(end)"
--sort=taggerdate
refs/tags
| tail -n2
I get:
a v0.11.0 a385a1c @2c3ef8cdb5068e47f818af0c2bb81c5a6a2b2056 0.11.0
a v0.11.1 55210a6 @9b389a86652517a49c025c40a2cd7bd614d3ace4 0.11.1
But on GitHub, when it runs the job on push of v0.11.1
:
a v0.10.0 b2e1fd0 @b746724eb7f2adbd254ebe66219d83fbad411326 0.10.0
a v0.11.0 a385a1c @2c3ef8cdb5068e47f818af0c2bb81c5a6a2b2056 0.11.0
This is the actual job and the commit. This is the tag but it’s likely to change what it points to.
Here’s how I actually make release semver=0.11.1 || make rollback tag=v0.11.1
:
.PHONY: release
release: pre-release gh-release
pre-release:
$(call check_defined, semver)
$(info Attempting to release $(semver))
./gradlew build --quiet
git tag -m $(semver) -a v$(semver)
./gradlew assemble shadowJar --quiet
./gradlew publishPlugins --validate-only --no-configuration-cache --warn
gh-release: build/libs/*.jar
$(call check_defined, semver)
git push --tags
and a synopsis of the job:
name: Release
on:
push:
tags:
- "v*.*.*"
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
So why is GitHub behaving differently than local git? Can I fix it?
2
Answers
I found this bug on the checkout action. This appears to be an acceptable workaround for my use case
Your "git tag -n" command shows the following:
And, in the "git for-each-ref" command you’re using the "–sort=taggerdate" and "| tail -n2" at the end. The "v0.11.1" tagger date may be older than the other two, and because of that, it is not being shown.
Remove the "| tail -n2" and analyse the result to understand better what’s happening.