How to upgrade the `3.6` version that was built with source to `4.4`?

I had installed MongoDB 3.6 by building manually from source code. Now I want to upgrade it to 4.4 while keeping the data. How should I go about it?
I’m interested in getting the instructions for macOS and Ubuntu@18.