mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-12-01 12:30:16 -05:00
3c7dbf3a16
Conflicts: - `.github/workflows/build-nightly.yml`: Upstream changed the environment variables used for defining the version number. This change occurs close to lines that were modified in glitch-soc to account for the different repositories to push to. Ported upstream changes. - `.github/workflows/build-push-pr.yml`: Upstream changed the environment variables used for defining the version number. This change occurs close to lines that were modified in glitch-soc to account for the different repositories to push to. Ported upstream changes. - `lib/mastodon/version.rb`: Upstream changed how the version string is built from environment variables. Adapted the logic to account for the `+glitch` in glitch-soc.
68 lines
1.3 KiB
Ruby
68 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Mastodon
|
|
module Version
|
|
module_function
|
|
|
|
def major
|
|
4
|
|
end
|
|
|
|
def minor
|
|
2
|
|
end
|
|
|
|
def patch
|
|
0
|
|
end
|
|
|
|
def default_prerelease
|
|
'beta2'
|
|
end
|
|
|
|
def prerelease
|
|
ENV['MASTODON_VERSION_PRERELEASE'].presence || default_prerelease
|
|
end
|
|
|
|
def build_metadata
|
|
['glitch', ENV.fetch('MASTODON_VERSION_METADATA', nil)].compact.join('.')
|
|
end
|
|
|
|
def to_a
|
|
[major, minor, patch].compact
|
|
end
|
|
|
|
def to_s
|
|
components = [to_a.join('.')]
|
|
components << "-#{prerelease}" if prerelease.present?
|
|
components << "+#{build_metadata}" if build_metadata.present?
|
|
components.join
|
|
end
|
|
|
|
def repository
|
|
ENV.fetch('GITHUB_REPOSITORY', 'glitch-soc/mastodon')
|
|
end
|
|
|
|
def source_base_url
|
|
ENV.fetch('SOURCE_BASE_URL', "https://github.com/#{repository}")
|
|
end
|
|
|
|
# specify git tag or commit hash here
|
|
def source_tag
|
|
ENV.fetch('SOURCE_TAG', nil)
|
|
end
|
|
|
|
def source_url
|
|
if source_tag
|
|
"#{source_base_url}/tree/#{source_tag}"
|
|
else
|
|
source_base_url
|
|
end
|
|
end
|
|
|
|
def user_agent
|
|
@user_agent ||= "#{HTTP::Request::USER_AGENT} (Mastodon/#{Version}; +http#{Rails.configuration.x.use_https ? 's' : ''}://#{Rails.configuration.x.web_domain}/)"
|
|
end
|
|
end
|
|
end
|