0

Working on CI and we would like to use tags from git for builds on Xcode Cloud. So idea is that we make atag like "SOMESTRING-XXX.YYY.ZZZ-BUILDNUMBER. Ok build number increments automatically with no problem, but getting the version number is kinda pain. My regex is a bit rusty. Currently I have:

version=$(echo $IN | sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p')

Which works ok for version format XXX.YYY.ZZZ, but fails when there is only one digit in last section ZZZ. Version sections could have up to 3 digits.

Matej P
  • 115
  • 1
  • 3
  • 11

1 Answers1

0

Ok got a solution:

version=$(echo $IN |  perl -pe '($_)=/([0-9]+([.][0-9]+)+)/')
Matej P
  • 115
  • 1
  • 3
  • 11