-
Notifications
You must be signed in to change notification settings - Fork 9
/
validate-version.sh
executable file
·59 lines (46 loc) · 1.88 KB
/
validate-version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
INPUT_TAG="$1"
if [ -z "$INPUT_TAG" ]; then
echo "Usage: $0 <tag>"
exit 1
fi
VERSION=${INPUT_TAG#v}
BAD=
if [ "$(jq -r .version packages/web-component/package.json)" != "$VERSION" ]; then
echo "ERROR: version mismatch in packages/web-component/package.json"
BAD=1
fi
if [ "$(jq -r .version packages/ngx-web-component/package.json)" != "$VERSION" ]; then
echo "ERROR: version mismatch in packages/ngx-web-component/package.json"
BAD=1
fi
if [ "$(jq -r '.peerDependencies."@readalongs/web-component"' packages/ngx-web-component/package.json)" != "$VERSION" ]; then
echo "ERROR: peer dependency on @readalongs/web-component version mismatch in packages/ngx-web-component/package.json"
BAD=1
fi
if [ "$(jq -r .singleFileBundleVersion packages/studio-web/package.json)" != "$VERSION" ]; then
echo "ERROR: singleFileBundleVersion mismatch in packages/studio-web/package.json"
BAD=1
fi
version_less_than() {
{ echo "$1"; echo "$2"; } | sort -V -C && [ "$1" != "$2" ]
}
NPM_VERSION_WEBC=$(npm view @readalongs/web-component version)
echo "Published NPM @readalongs/web-component version: $NPM_VERSION_WEBC"
NPM_VERSION_NGXWEBC=$(npm view @readalongs/ngx-web-component version)
echo "Published NPM @readalongs/ngx-web-component version: $NPM_VERSION_NGXWEBC"
echo "New version: $VERSION"
if [ "$NPM_VERSION_WEBC" != "$NPM_VERSION_NGXWEBC" ]; then
echo "WARNING: published NPM @readalongs/web-component and @readalongs/ngx-web-component versions differ"
fi
if ! version_less_than "$NPM_VERSION_WEBC" "$VERSION"; then
echo "ERROR: new version $VERSION is not greater than published NPM @readalongs/web-component version $NPM_VERSION_WEBC"
BAD=1
fi
if ! version_less_than "$NPM_VERSION_NGXWEBC" "$VERSION"; then
echo "ERROR: new version $VERSION is not greater than published NPM @readalongs/ngx-web-component version $NPM_VERSION_NGXWEBC"
BAD=1
fi
if [ -n "$BAD" ]; then
exit 1
fi