Skip to content

Instantly share code, notes, and snippets.

@tugberkugurlu
Created July 8, 2016 13:57
Show Gist options
  • Save tugberkugurlu/ea5c844236e29e45c1da0ce47a6a06e4 to your computer and use it in GitHub Desktop.
Save tugberkugurlu/ea5c844236e29e45c1da0ce47a6a06e4 to your computer and use it in GitHub Desktop.
Patch project.json version, requires jq to be available on path
#!/bin/bash
for i in "$@"
do
case $i in
-v=*|--version=*)
VERSIONNUMBER="${i#*=}"
shift # past argument=value
;;
*)
# unknown option
;;
esac
done
echo "VERSION = ${VERSIONNUMBER}"
if [ -z ${VERSIONNUMBER+x} ]
then
echo "No version is specified, defaulting to 0.0.0"
VERSIONNUMBER=0.0.0
fi
scriptsDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
rootDir="$(dirname "$scriptsDir")"
projectFiles=$rootDir/src/**/project.json
for projectFile in $projectFiles
do
echo "patching $projectFile with version $VERSIONNUMBER"
echo $(jq ". + { \"version\": \"$VERSIONNUMBER\" }" <<<$(jq 'del(.version)' <<<"$(cat $projectFile)")) > $projectFile
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment