From 40e9bcd1b4c9709c3a6e45a0136b12e6849d9d4e Mon Sep 17 00:00:00 2001
From: Peter Bacon Darwin <pete@bacondarwin.com>
Date: Mon, 31 Aug 2015 22:17:14 +0100
Subject: [PATCH] chore(scripts/publish): get dist-tag from package.json

Closes #12722
---
 package.json             |  1 +
 scripts/bower/publish.sh | 17 ++++-------------
 2 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/package.json b/package.json
index db977175c27d..2d15f9efb78f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,7 @@
 {
   "name": "angularjs",
   "branchVersion": "1.3.*",
+  "distTag": "previous_1_3",
   "repository": {
     "type": "git",
     "url": "https://github.com/angular/angular.js.git"
diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh
index e89f1ced0228..f4b52f157a08 100755
--- a/scripts/bower/publish.sh
+++ b/scripts/bower/publish.sh
@@ -110,19 +110,10 @@ function publish {
 
     # don't publish every build to npm
     if [ "${NEW_VERSION/+sha}" = "$NEW_VERSION" ] ; then
-      if [ "${NEW_VERSION/-}" = "$NEW_VERSION" ] ; then
-        if [[ $NEW_VERSION =~ ^1\.2\.[0-9]+$ ]] ; then
-          # publish 1.2.x releases with the appropriate tag
-          # this ensures that `npm install` by default will not grab `1.2.x` releases
-          npm publish --tag=old
-        else
-          # publish releases as "latest"
-          npm publish
-        fi
-      else
-        # publish prerelease builds with the beta tag
-        npm publish --tag=beta
-      fi
+      # get the npm dist-tag from a custom property (distTag) in package.json
+      DIST_TAG=$(readJsonProp "package.json" "distTag")
+      echo "-- Publishing to npm as $DIST_TAG"
+      npm publish --tag=$DIST_TAG
     fi
 
     cd $SCRIPT_DIR