Restart sbt from time to time when publishing

If sbt is not restarted, the JVM will fall back to interpreted mode
after some time. This makes compilation extremely slow.
Merge pull request #984 from gzm0/improve-publish-script

Restart sbt from time to time when publishing