Postgres is an excellent database, but, as of now, version 12 is two months old and the Installation Instructions are still based on Postgres 11.

First, add the version 12 repo to your apt sources:

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main 12" > /etc/apt/sources.list.d/PostgreSQL.list'

(Note: this supports either Ubuntu 16 (Xenial) or 18 (Bionic) by getting the release name from lsb_release)

Next, add the Postgres repo key:

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Update the system:

sudo apt-get -y update

Then finally, install Postgres 12

sudo apt-get -y install postgresql-12

Thanks for reading and please let me know if you have any thoughts or questions!