Short summary: I would like to change the default `publishTo` with an sbt task, but only in some cases. I'm trying to do something like:

```
val setSnapshot = taskKey[Unit]("changeRepo")

setSnapshot := {
  System.out.println(publishTo.value)
  publishTo in ThisBuild := Some("test" at "snapshot.myrepository")
  System.out.println(publishTo.value)
}

name := "Hello"
version := "1.0"
scalaVersion := "2.10.2"

publishTo in ThisBuild := Some("test" at "release.myrepository")

```

However, the `publishTo` does not change it's value. I learned [that `setting keys` are assigned only once](https://www.scala-sbt.org/1.x/docs/Basic-Def.html#Keys). Is `publishTo` a setting key? Is there no way to change the target later?

---

Context:

We want our server to build snapshots on any commit and releases on tags. We want it to release to two different repositories. Snapshots go in one and releases in another one. Is there a way to even change the isSnapshot configuration?

Ideally we would like to give our CI runner different commands it could run, like:

* `sbt setSnapshot publish`
* `sbt setRelease publish`

`setRelease` and `setSnapshot` would set the corresponding destination.

* `sbt publish`

> 
> Alternatively if it was possible to just use publish, and then check if "isSnapshot" is `true` or `false` and then publish in one or the other repository. However, I haven't even figured out how isSnapshot can be modified, without touching the `build.sbt`-file itself.
> 
> 
> 

I've been going through some of the build.sbt documentation, but I haven't found the right page yet...

* <https://www.scala-sbt.org/1.0/docs/Getting-Started.html>
* <https://www.scala-sbt.org/1.0/docs/Task-Graph.html>

Am I attacking this problem from a completely wrong angle?