[tooling] Make import of publishing script at the 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.