feat: add a version checker and bump to 1.0.1

Since this is being developed alongside other projects, adding a version checker is going to save some time.
This commit is contained in:
Linden
2021-11-14 02:03:19 +11:00
parent 6aede19f4e
commit a4c06746c5
3 changed files with 43 additions and 5 deletions

28
version.lua Normal file
View File

@@ -0,0 +1,28 @@
CreateThread(function()
Wait(1000)
local resource = GetCurrentResourceName()
local url = GetResourceMetadata(resource, 'repository', 0)
local version = GetResourceMetadata(resource, 'version', 0)
PerformHttpRequest(('%s/master/fxmanifest.lua'):format(url:gsub('github.com', 'raw.githubusercontent.com')), function(error, response)
if error ~= 200 then
local latest = response:match('%d%.%d+%.%d+')
print(version, latest)
if version == latest then
local curMajor, curMinor = string.strsplit('.', version)
local newMajor, newMinor = string.strsplit('.', response:match('%d%.%d+%.%d+'))
local link = ('%s/archive/refs/tags/%s.zip'):format(url, latest, latest)
if tonumber(curMajor) < tonumber(newMajor) then
latest = 'A major update'
elseif tonumber(curMinor) < tonumber(newMinor) then
latest = 'An update'
else
latest = 'A patch'
end
print(('^3%s is available for oxmysql - please download the latest release (current version: %s)\n ^3- %s^0'):format(latest, version, link))
end
end
end, 'GET')
end)