From 0faef1e4cc135509572fffd59375d35fc887d8b8 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Wed, 11 Mar 2015 14:54:44 -0700 Subject: [PATCH] Add a script to check versions. This script checks for versioning mistakes and will prevent npm publication if any of the checks fail. This also drops the check.sh script, which nobody was using. Related to #30 Change-Id: Ic8e504515ac31beb7833207aa2ac463d40cfae88 --- build/check.sh | 24 --------------- build/checkversion.sh | 70 +++++++++++++++++++++++++++++++++++++++++++ build/lib.sh | 4 ++- package.json | 2 +- tutorials/dev.html | 1 - 5 files changed, 74 insertions(+), 27 deletions(-) delete mode 100755 build/check.sh create mode 100755 build/checkversion.sh diff --git a/build/check.sh b/build/check.sh deleted file mode 100755 index a8d9278406..0000000000 --- a/build/check.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Copyright 2014 Google Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -dir=$(dirname $0)/.. - -set -e - -"$dir"/build/build.sh -"$dir"/build/lint.sh - -echo "Compiled binary is $(cat "$dir"/shaka-player.compiled.js | wc -c) bytes." diff --git a/build/checkversion.sh b/build/checkversion.sh new file mode 100755 index 0000000000..6e1889090d --- /dev/null +++ b/build/checkversion.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# Copyright 2015 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +dir=$(dirname $0)/.. +. "$dir"/build/lib.sh + +set -e + +NPM_VERSION=$( + grep '"version"' "$dir"/package.json | + cut -f 2 -d : | sed -e 's/.*"\(.*\)".*/\1/' +) +PLAYER_VERSION=$( + grep GIT_VERSION "$dir"/lib/player/player.js | grep goog.define | + cut -f 2 -d , | sed -e "s/.*'\\(.*\\)'.*/\\1/" +) +CHANGELOG_VERSION=$( + grep '##' "$dir"/CHANGELOG.md | head -1 | + cut -f 2 -d ' ' +) + +rv=0 + +echo "git version = $GIT_VERSION" +echo "npm version = $NPM_VERSION" +echo "player version = $PLAYER_VERSION" +echo "changelog version = $CHANGELOG_VERSION" +echo + +if echo "$GIT_VERSION" | grep -q dirty; then + echo "Git version is dirty!" 1>&2 + rv=1 +elif echo "$GIT_VERSION" | egrep -q '(-|unknown)'; then + echo "Git version is not a tag!" 1>&2 + rv=1 +elif ! echo "$GIT_VERSION" | grep -q '^v[0-9]\+\.[0-9]\+\.[0-9]\+$'; then + echo "Git version is a malformed release version!" 1>&2 + echo "It should be three ints separated by dots, with a 'v' prepended." 1>&2 + rv=1 +else + if [ "v$NPM_VERSION" != "$GIT_VERSION" ]; then + echo "NPM version does not match git version!" 1>&2 + rv=1 + fi + + if [ "$PLAYER_VERSION" != "$GIT_VERSION-debug" ]; then + echo "Player version does not match git version!" 1>&2 + rv=1 + fi + + if [ "v$CHANGELOG_VERSION" != "$GIT_VERSION" ]; then + echo "Changelog version does not match git version!" 1>&2 + rv=1 + fi +fi + +exit $rv diff --git a/build/lib.sh b/build/lib.sh index 0b5f6c6c38..f0c68eb3dd 100644 --- a/build/lib.sh +++ b/build/lib.sh @@ -14,6 +14,8 @@ dir=$(dirname $0)/.. +GIT_VERSION=$(cd "$dir"; git describe --tags --dirty || echo unknown) + closure_opts=" --language_in ECMASCRIPT5 --language_out ECMASCRIPT5 @@ -56,7 +58,7 @@ closure_opts=" -D goog.ENABLE_DEBUG_LOADER=false -D shaka.asserts.ENABLE_ASSERTS=false -D shaka.log.MAX_LOG_LEVEL=0 - -D GIT_VERSION='$(cd "$dir"; git describe --tags --dirty || echo unknown)' + -D GIT_VERSION='$GIT_VERSION' " set -e diff --git a/package.json b/package.json index a8f9737574..d3f97eb409 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,6 @@ } ], "scripts": { - "prepublish": "./build/all.sh" + "prepublish": "./build/checkversion.sh && ./build/all.sh" } } diff --git a/tutorials/dev.html b/tutorials/dev.html index e2f5d80414..3d3170d7b5 100644 --- a/tutorials/dev.html +++ b/tutorials/dev.html @@ -168,7 +168,6 @@

shaka-player.compiled.js
  • gendeps.sh - computes dependencies for running non-compiled code
  • lint.sh - checks the code for style issues
  • -
  • check.sh - combination of build.sh and lint.sh
  • all.sh - combination of gendeps.sh, build.sh, and lint.sh
  • docs.sh - generate documentation