diff options
author | 0neGal <mail@0negal.com> | 2022-02-19 22:05:05 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2022-02-19 22:05:05 +0100 |
commit | a3741b2934a8c8dffd3f665576f33324e89a4a1b (patch) | |
tree | 0c23cce89061b4361028e0ebf516ff4f35dc5187 /build/publish.sh | |
parent | 47f2e089dc94cbb33800313173548cb15f0aeec1 (diff) | |
download | Viper-a3741b2934a8c8dffd3f665576f33324e89a4a1b.tar.gz Viper-a3741b2934a8c8dffd3f665576f33324e89a4a1b.zip |
updated build scripts/code tests
build/langs.js now gives more info and has colors. It also changes it's
exit code if an error happened, we then use that in build/publish.sh to
catch localization errors before publishing. We also ensure that version
numbers are set correctly.
Then at last we will make sure $GH_TOKEN is set, and if not, prompt for
the token, to make sure you don't build everything then error out when
you forgot to put in your token.
Diffstat (limited to 'build/publish.sh')
-rwxr-xr-x | build/publish.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/build/publish.sh b/build/publish.sh new file mode 100755 index 0000000..c8f7832 --- /dev/null +++ b/build/publish.sh @@ -0,0 +1,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 +} + +GH_TOKEN="$GH_TOKEN" + +[ "$GH_TOKEN" = "" ] && { + echo "GH_TOKEN is not set, please type it below:" + read -p "> " GH_TOKEN +} + +npm run publish |