repo: janusweb
action: commit
revision: 
path_from: 
revision_from: dc8e5ea7e1a38651443ac712d8a8867cb15a8223:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit dc8e5ea7e1a38651443ac712d8a8867cb15a8223
Author: James Baicoianu 
Date:   Sun Jan 15 00:39:36 2017 -0800

    Improved build and release scripts

diff --git a/utils/build.sh b/utils/build.sh
index 9327edd98f14ea13a75f9dc06b9e717720b4c748..
index ..20e0f302a5afdc211e6748ff1219b858bc01d041 100755
--- a/utils/build.sh
+++ b/utils/build.sh
@@ -1,15 +1,16 @@
-#!/bin/sh
+#!/bin/bash

-BUILDDIR=$(pwd)/build
-RELDIR=$(pwd)/release
 VERSION=$(node -pe "require('./package.json').version")
+BUILDROOT=$(pwd)/build
+BUILDBASE=${VERSION}
+BUILDDIR=${BUILDROOT}/${BUILDBASE}
+ZIPNAME=janusweb-${VERSION}


+echo $BUILDROOT
+echo $BUILDDIR
 if [ ! -e "$BUILDDIR" ]; then
-  mkdir "$BUILDDIR"
-fi
-if [ ! -e "$RELDIR" ]; then
-  mkdir "$RELDIR"
+  mkdir -p "$BUILDDIR"
 fi

 if [ -e "$BUILDDIR/media" ]; then
@@ -34,5 +35,6 @@ fi
 mv janusweb.css janusweb.js "$BUILDDIR"
 echo Built new release in \"$BUILDDIR/\"

-cd $BUILDDIR
-tar czf $RELDIR/janusweb-$VERSION.tar.gz .
+cd $BUILDROOT
+tar czf "$ZIPNAME.tar.gz" "$BUILDBASE" --transform=s/${BUILDBASE}/$ZIPNAME/ 
+
diff --git a/utils/promote.sh b/utils/promote.sh
new file mode 100755
index 0000000000000000000000000000000000000000..9991d17d1de7340cc1f60c8b2311690d031f82d0
--- /dev/null
+++ b/utils/promote.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# Usage: promote.sh  
+
+VERSION=$1
+TO=$2
+
+function join_by { local IFS="$1"; shift; echo "$*"; }
+if [ -z "$TO" ]; then
+  IFS='.' read -ra parts <<< "$VERSION"
+  unset 'parts[${#parts[@]}-1]'  
+  TO=$(join_by . ${parts[@]})
+fi
+
+
+echo "$VERSION => $TO"
+cd build/
+
+if [ -L $TO ]; then 
+  rm $TO
+fi
+ln -sf $VERSION $TO
diff --git a/utils/release.sh b/utils/release.sh
new file mode 100755
index 0000000000000000000000000000000000000000..4d6a67133a0c3b8389509695013bcafecb1ea57f
--- /dev/null
+++ b/utils/release.sh
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+# Process:
+#  - increment version number
+#  - update package.json
+#  - run build script
+#  - create zip
+#  - publish to npm
+#  - git tag
+#  - update latest version aliases
+#  - push to s3
+#  - publish release notes
+
+
+# The build will be stored by version, and then aliased out to its parent version numbers.  
+# For example, if we just released 0.9.8, the following files would all be the same:
+#
+#   build/v0.9.8/janusweb.js
+#   build/v0.9/janusweb.js
+#   build/v0/janusweb.js
+#   build/janusweb.js
+#
+# This allows us to keep all previous versions around, and website authors can choose which
+# version they link to.  Users are encouraged to link to the latest minor version so they 
+# receive bugfixes and 
+# they are they can just link to a more specific that was known to work
+
+RELTYPE=$1
+# RELTYPE can be:
+# - major
+# - minor
+# - patch
+# - set
+
+VERSIONFILE=VERSION
+PACKAGEFILE=package.json
+
+function get_current_version() {
+  cat $VERSIONFILE
+}
+function join_by { local IFS="$1"; shift; echo "$*"; }
+function get_next_version() {
+  RELTYPE=$1
+  CURVER=$(get_current_version)
+  IFS='.' read -ra VERSIONS <<< "$CURVER"
+
+  #echo "version $CURVER"
+  #echo "Reltype $RELTYPE"
+
+  case $RELTYPE in
+    "major")
+      NUM=${VERSIONS[0]}
+      VERSIONS[0]=$((NUM + 1))
+      VERSIONS[1]=0
+      VERSIONS[2]=0
+      ;;
+    "minor")
+      NUM=${VERSIONS[1]}
+      VERSIONS[1]=$((NUM + 1))
+      VERSIONS[2]=0
+      ;;
+    "patch")
+      NUM=${VERSIONS[2]}
+      VERSIONS[2]=$((NUM + 1))
+      ;;
+    "set")
+      IFS='.' read -ra VERSIONS <<< "$2"
+      ;;
+  esac
+ 
+  join_by . "${VERSIONS[@]}"
+}
+function update_version {
+  NEWVERSION=$1
+  echo $NEWVERSION >$VERSIONFILE
+  npm 
+  
+}
+
+NEWVER=$(get_next_version "$RELTYPE")
+echo $NEWVER
+
+
+

-----END OF PAGE-----