1
1
#! /usr/bin/env bash
2
2
# Automatically update versions in files and create an autorelease.
3
3
# Requires the github CLI and jq (if you don't update the version manually).
4
+ EXIT=" "
4
5
NEW_VERSION=$1
5
6
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
+
6
30
if [ -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
8
33
fi
9
34
10
35
# Let users edit release-notes.txt for release notes.
@@ -30,10 +55,10 @@ rm -f manifest-beta.tmp.json
30
55
rm -f versions.tmp.json
31
56
32
57
# 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
37
62
38
63
# Overwrite the beta manifest as well.
39
64
cp manifest.json manifest-beta.json
0 commit comments