Updating mastodon (v3.5.3 to v4.0.1)
These are the steps to upgrade mastodon from v3.5.3 to v4.0.1. The entire process takes a bit of time since we are updating ruby as well (don't worry this is pain-free). Start by logging in on the machine.
Then login as mastodon.
$ sudo su - mastodon
Navigate to the live directory and fetch the latest version
$ cd live
$ git fetch --tags
$ git checkout v4.0.1
Update ruby and install the missing gems, this takes the most time.
$ rbenv install
$ bundle install
$ yarn install
Now run the pre-deployment database scripts
$ SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate
Once those have completed, exit the limited session (and become root) to restart the mastodon services.
$ exit
$ systemctl restart mastodon-*
Log back in, navigate to live
and, precompile the assets (another long wait) and perform the post-deployment database scripts.
$ sudo su - mastodon
$ cd live
$ RAILS_ENV=production bundle exec rails assets:precompile
$ RAILS_ENV=production bundle exec rails db:migrate
And finally logout and restart the mastodon services one more time.
$ exit
$ systemctl restart mastodon-*
And if you want to install mastodon below is a tutorial.