Use nexus-staging-maven-plugin

The nexus-staging-maven-plugin allows you to deploy to
sonatype, and automatically close and release a repository
without having to log into the sonatype UI. This will allow
us to use sonatype in a CD pipeline.