11#! /usr/bin/env bash
22# Automatically update versions in files and create an autorelease.
33# Requires the github CLI and jq (if you don't update the version manually).
4+ EXIT=" "
45NEW_VERSION=$1
56
7+ if [ -z " $EDITOR " ]; then
8+ echo " Specify which editor to use in EDITOR, or by doing: EDITOR=vi ./scripts/release 0.x.y"
9+ EXIT=1
10+ fi
11+
12+ if ! command -v jq 2>&1 > /dev/null; then
13+ echo " This script relies on the 'jq' command, please install it"
14+ EXIT=1
15+ fi
16+
17+ if ! command -v gh 2>&1 > /dev/null; then
18+ echo " This script relies on the 'gh' command from the Github CLI package, please install it"
19+ EXIT=1
20+ fi
21+
22+ if [ $EXIT ]; then
23+ exit $EXIT
24+ fi
25+
26+ if [ -z " $NEW_VERSION " ]; then
27+ NEW_VERSION=$( jq -r " .version" manifest-beta.json | awk -F. -v OFS=. ' {$NF += 1 ; print}' )
28+ fi
29+
630if [ -z " $NEW_VERSION " ]; then
7- NEW_VERSION=$( jq -r " .version" manifest-beta.json | awk -F. -v OFS=. ' {$NF += 1 ; print}' )
31+ echo " Auto-generating next version number failed, please specify next version : ./scripts/release 0.x.y"
32+ exit 1
833fi
934
1035# Let users edit release-notes.txt for release notes.
@@ -30,10 +55,10 @@ rm -f manifest-beta.tmp.json
3055rm -f versions.tmp.json
3156
3257# Rewrite versions in relevant files.
33- # no jq# jq ".version=\"${NEW_VERSION}\"" package.json > package.tmp.json && mv package.tmp.json package.json
34- # no jq# jq ".version=\"${NEW_VERSION}\"" manifest.json > manifest.tmp.json && mv manifest.tmp.json manifest.json
35- # no jq# jq ".version=\"${NEW_VERSION}\"" manifest-beta.json > manifest-beta.tmp.json && mv manifest-beta.tmp.json manifest-beta.json
36- # no jq# jq ". + {\"${NEW_VERSION}\": \"0.12.0\"}" versions.json > versions.tmp.json && mv versions.tmp.json versions.json
58+ jq " .version=\" ${NEW_VERSION} \" " package.json > package.tmp.json && mv package.tmp.json package.json
59+ jq " .version=\" ${NEW_VERSION} \" " manifest.json > manifest.tmp.json && mv manifest.tmp.json manifest.json
60+ jq " .version=\" ${NEW_VERSION} \" " manifest-beta.json > manifest-beta.tmp.json && mv manifest-beta.tmp.json manifest-beta.json
61+ jq " . + {\" ${NEW_VERSION} \" : \" 0.12.0\" }" versions.json > versions.tmp.json && mv versions.tmp.json versions.json
3762
3863# Overwrite the beta manifest as well.
3964cp manifest.json manifest-beta.json
0 commit comments