Skip to content

Instantly share code, notes, and snippets.

@michaellihs
Last active August 14, 2022 07:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaellihs/bd13d7f7d966d2ccf7ab57bc651c1d12 to your computer and use it in GitHub Desktop.
Save michaellihs/bd13d7f7d966d2ccf7ab57bc651c1d12 to your computer and use it in GitHub Desktop.
Groovy script that returns an array of Git tags with versions
def gitTags = ("git tag").execute()
def tags = gitTags.text.readLines()
.collect { it.split() }
.unique()
.findAll { it =~ /\d+\.\d+\.\d+/ }
tags.reverse(true)
println tags
/*
for
$ git tag
1.0.0
1.0.1
2.0.1
2.1.1
2.1.2
test
this will return
[[2.1.2], [2.1.1], [2.0.1], [1.0.1], [1.0.0]]
*/
@michaellihs
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment