Skip to content

Instantly share code, notes, and snippets.

@thevangelist
Created September 30, 2016 08:45
Show Gist options
  • Save thevangelist/5a7b732406d2e713ae1e6de073a30403 to your computer and use it in GitHub Desktop.
Save thevangelist/5a7b732406d2e713ae1e6de073a30403 to your computer and use it in GitHub Desktop.
Semver versioning with git tags & npm version
#!/bin/sh
# Convenience script for versioning
# Pass a semver-formatted version number to this script such as `npm version 2.1.0`.
#
# You'll get:
# 1) git tag such as v2.1.0
# 2) new version to `package.json`
npm version $1
@keveri
Copy link

keveri commented Sep 30, 2016

Here is a way to validate the first arguments presence:

version="$1"

if [ -z "$version" ]; then
    echo "First argument should be a semver-formatted version number such as '2.1.0'."
    exit 1
fi

npm version "$version"

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