Skip to content

Instantly share code, notes, and snippets.

@blndev
Created June 11, 2018 08:09
Show Gist options
  • Save blndev/ea551b4551a50e0359336e6e725922b1 to your computer and use it in GitHub Desktop.
Save blndev/ea551b4551a50e0359336e6e725922b1 to your computer and use it in GitHub Desktop.
Pure BASH based Version extractor
#could be injected by ci pipeline or extracted from git
tag=RELEASE#1.0.7-alpha
#Split by "#" to get Version substring
tagversion=( ${tag//#/ } )
product_version="${tagversion[1]}"
echo "${product_version}"
#Split by "."
semver=( ${product_version//./ } )
major="${semver[0]}"
minor="${semver[1]}"
patch="${semver[2]}"
#Results
echo "${major}"
echo "${minor}"
echo "${patch}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment