/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
And that's all to get it in your system. But I don't want explain what's homebrew in this post, I just want to share a way to update the already installed packages by brew on your MacOS. You only need these two steps:
brew update
brew cask outdated | xargs brew cask reinstall
And that's all. Brew will update your outdated packages.