[tooling] Mode publishing script import to top

It felts awkward to import publishing script only at the bottom of
this build file, because it needs information that comes before, such
as sources jar settings.

This puts the publishing script import on top, among the others, but
enclosed in a afterEvaluate closure, to ensure the same and correct
behaviour as before.