Move publishing logic into gradle build script.