0

I want to create a single command that would do following:

  • increase the package.json version (I could do this by running npm version patch)
  • create Github release with that version as tag (not sure how to achieve this step?)

Brownie points if I could supply patch/minor/major flag while running the command so that npm version _flag_ runs instead of always patching.

I'm using gh package https://cli.github.com/manual/gh_release_create

torek
  • 448,244
  • 59
  • 642
  • 775
GorvGoyl
  • 42,508
  • 29
  • 229
  • 225

1 Answers1

0

To get the version node -pe "require('./package.json').version"

A script with optional argument as asked, if no args this will do a patch. Then launch interactive release creation with the new version

#!/bin/sh

if [ $# -eq 0 ]
then
    action="patch"
else
    case $1 in
        minor | major | patch)
            action=$1
            ;;
        *)
            echo "Unknow $1 command"
            return -1
            ;;
    esac
fi
npm version $action
version=`node -pe "require('./package.json').version"`

echo "new version $version"
gh release create $version
Ôrel
  • 7,044
  • 3
  • 27
  • 46