aboutsummaryrefslogtreecommitdiff
path: root/build/publish.sh
blob: 042b7c165b510f3df28878fa9d808b4715aaa38a (plain)
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
#!/bin/sh

VERSION="v$(jq '.version' package.json -r)"
LOCK1="v$(jq '.version' package-lock.json -r)"
LOCK2="v$(jq '.packages[""].version' package-lock.json -r)"

REPO="$(jq '.repository.url' package.json -r | sed 's/.*.com\///g')"

REMOTEVERSION="$(curl --silent "https://api.github.com/repos/0neGal/viper/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')"

[ "$REMOTEVERSION" = "$VERSION" ] && {
	echo "A release already exists with the current version number!"
	exit 1
}

[ "$VERSION" != "$LOCK1" ] && {
	echo "Two seperate version numbers in package.json and package-lock.json"
	echo "  $VERSION, $LOCK1"
	exit 1
}

[ "$LOCK1" != "$LOCK2" ] && {
	echo "Version mismatches in package-lock.json"
	echo "  $LOCK1, $LOCK2"
	exit 1
}


node build/langs.js || {
	echo "Please fix localization errors before publishing..."
	exit 1
}

TOKEN="$GH_TOKEN"

[ "$TOKEN" = "" ] && {
	echo "GH_TOKEN is not set, please type it below:"
	read -p "> " TOKEN
}

GH_TOKEN="$TOKEN" npm run publish