The status attribute is what you are looking for. See below:
<g:each collection=${books} var="abook" status="i">
${i}
</g:each>
if you call $ {i} inside each tag, it will return the current iteration counter.
Assuming that the book collection contains 5 books, the output will be:
0
1
2
3
4
source
share