Skip to content

Instantly share code, notes, and snippets.

@sergiofilhowz
Created November 10, 2017 02:42
Show Gist options
  • Save sergiofilhowz/fb118bf2bf7423dba3529d93e00a4772 to your computer and use it in GitHub Desktop.
Save sergiofilhowz/fb118bf2bf7423dba3529d93e00a4772 to your computer and use it in GitHub Desktop.
use npm version to set prerelease version equal to Circle CI build number
# reads version from package.json and sets prelease equal to Circle CI build number
if [ $CI ] && [ $CIRCLE_BUILD_NUM ]
then
newversion=$(echo $npm_package_version | sed -e "s/^\([0-9]*\.[0-9]*\.[0-9]*\-[a-z]*\).[0-9]*$/\1.$CIRCLE_BUILD_NUM/")
echo "Setting version to $newversion"
# uses npm-version to set version in package.json
# see https://docs.npmjs.com/cli/version
npm version $newversion --no-git-tag-version
git add package.json
git commit -m "updated version to $newversion [ci skip]"
else
echo "Don't forget to update the build version!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment