diff --git a/app/helpers/http_helper.rb b/app/helpers/http_helper.rb
index 1e1ac82567cdd58ca4f57b342edddbbe7bd9ff6b..1697de746ea6398601887e534a79566bedb5dff4 100644
--- a/app/helpers/http_helper.rb
+++ b/app/helpers/http_helper.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module HttpHelper
-  USER_AGENT = "#{HTTP::Request::USER_AGENT} (Mastodon/#{Mastodon::VERSION}; +http://#{Rails.configuration.x.local_domain}/)"
+  USER_AGENT = "#{HTTP::Request::USER_AGENT} (Mastodon/#{Mastodon::Version}; +http://#{Rails.configuration.x.local_domain}/)"
 
   def http_client(options = {})
     timeout = { write: 10, connect: 10, read: 10 }.merge(options)
diff --git a/app/presenters/instance_presenter.rb b/app/presenters/instance_presenter.rb
index e583a38d0ef9cff95270499734e5b440451ee41b..9a69809d0e584137fd0c2555abdcfd6ae4d283aa 100644
--- a/app/presenters/instance_presenter.rb
+++ b/app/presenters/instance_presenter.rb
@@ -27,6 +27,6 @@ class InstancePresenter
   end
 
   def version_number
-    Mastodon::VERSION
+    Mastodon::Version
   end
 end
diff --git a/app/views/api/v1/instances/show.rabl b/app/views/api/v1/instances/show.rabl
index e1d4700a0c36fef28681b66ef8179ce193b8a647..8ab3fe0caeb4be6650686f96108ac51e14561a3b 100644
--- a/app/views/api/v1/instances/show.rabl
+++ b/app/views/api/v1/instances/show.rabl
@@ -4,4 +4,4 @@ node(:uri)         { site_hostname }
 node(:title)       { Setting.site_title }
 node(:description) { Setting.site_description }
 node(:email)       { Setting.site_contact_email }
-node(:version)     { Mastodon::VERSION }
+node(:version)     { Mastodon::Version }
diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb
index 51cf2e5f820f6802d8b8efbd7b583fd2506e690a..4ea9bab360899eb756c5dd507ff489e964c596a5 100644
--- a/lib/mastodon/version.rb
+++ b/lib/mastodon/version.rb
@@ -1,5 +1,31 @@
 # frozen_string_literal: true
 
 module Mastodon
-  VERSION = '1.2.2'
+  module Version
+    module_function
+
+    def major
+      1
+    end
+
+    def minor
+      3
+    end
+
+    def patch
+      0
+    end
+
+    def pre
+      nil
+    end
+
+    def to_a
+      [major, minor, patch, pre].compact
+    end
+
+    def to_s
+      to_a.join('.')
+    end
+  end
 end