nyastodon/lib/mastodon/version.rb
Claire 3c7dbf3a16 Merge commit '5694e24bbf9afccbbf1b44d3a405a4e2bc0ff08d' into glitch-soc/merge-upstream
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.
2023-09-02 11:56:09 +02:00

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