Add real release version into the running code (#14870)
* Add real release version into the running code * Fix warnings
This commit is contained in:
parent
bbc79821d0
commit
3801789e8f
2 changed files with 22 additions and 1 deletions
|
|
@ -13,7 +13,7 @@ module Api
|
|||
name: Settings::Community.community_name,
|
||||
registered_users_count: User.registered.estimated_count,
|
||||
tagline: Settings::Community.tagline,
|
||||
version: "edge.#{Time.now.utc.strftime('%Y%m%d')}.0",
|
||||
version: release_version,
|
||||
visibility: visibility
|
||||
}, status: :ok
|
||||
end
|
||||
|
|
@ -25,6 +25,24 @@ module Api
|
|||
|
||||
Settings::UserExperience.public ? "public" : "private"
|
||||
end
|
||||
|
||||
def release_version
|
||||
File.read(Rails.root.join(".release-version"))
|
||||
|
||||
# Accommodate the .release-version file not existing in the case where
|
||||
# this deployment is deployed from a checkout/snapshot of the code.
|
||||
rescue StandardError
|
||||
# Get the latest modified file in the app. We don't use git in case it's
|
||||
# being run from a snapshot of the code outside a git repo (for example:
|
||||
# https://github.com/forem/forem/archive/refs/heads/main.zip), but
|
||||
# instead we use the latest modified time ("mtime") from application
|
||||
# code.
|
||||
latest_mtime = Dir[Rails.root.join("{app,config,db,lib}/**/*")]
|
||||
.max_by { |filename| File.mtime(filename) }
|
||||
.then { |filename| File.mtime(filename) }
|
||||
|
||||
"edge.#{latest_mtime.strftime('%Y%m%d')}.0"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ begin
|
|||
puts "Merged #{source} into #{channel}"
|
||||
|
||||
begin
|
||||
run "echo '#{tag}' > .release-version"
|
||||
run "git add .release-version"
|
||||
run "git commit --message 'Version #{tag}'"
|
||||
run "git tag #{tag}"
|
||||
puts "Tagged #{tag}"
|
||||
rescue StandardError
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue