build: improved getting recent tag name with the for-each-ref command.