title: How to publish only when on master branch under Travis and sbt 0.13
body: <p>I'm using Travis for continuous build and integration.</p>
  
  <pre><code>after_success:
  - sbt publish
  </code></pre>
  
  <p>While we want Travis to build all of our branches and pull requests, we only want it to <code>publish</code> when on <code>master</code> branch.</p>
  
  <pre><code>publishTo &lt;&lt;= version { (v: String) =&gt;
    val nexus = s"asdf"
    /* Don't let Travis publish when building pull requests.
     * $TRAVIS_PULL_REQUEST == "false" if it's not a pull request.  So we wan't publishTo to be
     * None when TRAVIS_PULL_REQUEST != false.
     */
    if(Try(sys.env("TRAVIS_PULL_REQUEST")).getOrElse("false") != "false")
      None
    /* Don't let Travis publish except when building master. */
    if(Try(sys.env("TRAVIS_BRANCH")).map(_ != "master").getOrElse(false))
      None
    else if(v.trim.endsWith("SNAPSHOT"))
      Some("snapshots" at nexus + "snapshots")
    // don't let Travis publish releases, either
    else if(Try(sys.env("TRAVIS")).getOrElse("false") == "true")
      None
    else
      Some("releases"  at nexus + "releases")
  })
  </code></pre>
  
  <p>The problem with this approach is that Travis compiles branches twice because it fails publishing at the very last step.</p>
  
  <p>How can Travis be completely prevented from running <code>sbt publish</code> when on non-<code>master</code> branch? </p>