mirror of
https://github.com/TangentFoxy/love-release.git
synced 2025-07-28 02:52:20 +00:00
Use LÖVE new versionning scheme. Drop semver dependency. #53
This commit is contained in:
@@ -19,7 +19,6 @@ dependencies = {
|
||||
"luafilesystem",
|
||||
"lua-zip",
|
||||
"middleclass",
|
||||
"semver",
|
||||
}
|
||||
build = {
|
||||
type = "builtin",
|
||||
|
@@ -4,10 +4,8 @@
|
||||
|
||||
local fs = require 'luarocks.fs'
|
||||
local loadconf = require 'loadconf'
|
||||
local semver = require 'semver'
|
||||
|
||||
local utils = require 'love-release.utils'
|
||||
|
||||
local ver = utils.love.ver
|
||||
|
||||
local pipe = {}
|
||||
|
||||
@@ -37,7 +35,7 @@ function pipe.pipe(project)
|
||||
|
||||
local function setLoveVersion(v)
|
||||
if type(v) == "string" and v ~= "" then
|
||||
local version = semver(v)
|
||||
local version = ver(v)
|
||||
if not utils.love.isSupported(version) then
|
||||
local scriptLoveVersion = project.loveVersion
|
||||
err("CONF: Your LÖVE conf version ("..v
|
||||
|
@@ -3,14 +3,14 @@
|
||||
-- @usage env(project)
|
||||
|
||||
local fs = require 'luarocks.fs'
|
||||
local semver = require 'semver'
|
||||
local utils = require 'love-release.utils'
|
||||
local ver = utils.love.ver
|
||||
|
||||
local pipe = {}
|
||||
|
||||
|
||||
--- Gets the version of the installed LÖVE.
|
||||
-- @treturn semver LÖVE version.
|
||||
-- @treturn ver LÖVE version.
|
||||
-- @local
|
||||
local function getSystemLoveVersion()
|
||||
local handle = io.popen('love --version')
|
||||
@@ -18,12 +18,12 @@ local function getSystemLoveVersion()
|
||||
handle:close()
|
||||
local version = result:match('%d+%.%d+%.%d+')
|
||||
if version then
|
||||
return semver(version)
|
||||
return ver(version)
|
||||
end
|
||||
end
|
||||
|
||||
--- Gets the latest LÖVE version from the web.
|
||||
-- @treturn semver LÖVE version.
|
||||
-- @treturn ver LÖVE version.
|
||||
-- @local
|
||||
local function getWebLoveVersion()
|
||||
local releasesPath = utils.cache.."/releases.xml"
|
||||
@@ -35,17 +35,17 @@ local function getWebLoveVersion()
|
||||
local releasesXml = io.open(releasesPath, "rb")
|
||||
local version = releasesXml:read("*a"):match("<title>(%d+%.%d+%.%d+)")
|
||||
releasesXml:close()
|
||||
return semver(version)
|
||||
return ver(version)
|
||||
else
|
||||
return nil, err
|
||||
end
|
||||
end
|
||||
|
||||
--- Gets the latest LÖVE version from the script, the system and the web.
|
||||
-- @tparam semver script script version.
|
||||
-- @tparam semver system system version.
|
||||
-- @tparam semver web web version.
|
||||
-- @treturn semver the latest version.
|
||||
-- @tparam ver script script version.
|
||||
-- @tparam ver system system version.
|
||||
-- @tparam ver web web version.
|
||||
-- @treturn ver the latest version.
|
||||
-- @local
|
||||
local function getLatestLoveVersion(script, system, web)
|
||||
local version = script
|
||||
@@ -79,7 +79,7 @@ function pipe.pipe(project)
|
||||
|
||||
local systemLoveVersion = getSystemLoveVersion()
|
||||
local webLoveVersion = getWebLoveVersion()
|
||||
local scriptLoveVersion = utils.love.lastVersion()
|
||||
local scriptLoveVersion = utils.love.lastVersion
|
||||
local isSupported = utils.love.isSupported
|
||||
|
||||
if systemLoveVersion and not isSupported(systemLoveVersion) then
|
||||
|
@@ -217,7 +217,7 @@ function Project:setPackage(package)
|
||||
end
|
||||
|
||||
--- Sets the LÖVE version used.
|
||||
-- @tparam semver version the LÖVE version.
|
||||
-- @tparam ver version the LÖVE version.
|
||||
-- @treturn project self.
|
||||
function Project:setLoveVersion(version)
|
||||
self.loveVersion = version
|
||||
|
@@ -3,10 +3,10 @@
|
||||
-- @usage macosx(project)
|
||||
|
||||
local fs = require "luarocks.fs"
|
||||
local semver = require "semver"
|
||||
local zip = require "brimworks.zip"
|
||||
local Script = require "love-release.script"
|
||||
local utils = require "love-release.utils"
|
||||
local ver = utils.love.ver
|
||||
|
||||
local s = {}
|
||||
|
||||
@@ -26,12 +26,14 @@ function s.script(project)
|
||||
script:createLoveFile()
|
||||
fs.change_dir(project.releaseDirectory)
|
||||
|
||||
local prefix = "love-"..tostring(project.loveVersion).."-macosx-"
|
||||
local prefix = "love-"..tostring(project.loveVersion).."-macos"
|
||||
local bin
|
||||
if project.loveVersion >= semver'0.9.0' then
|
||||
bin = prefix.."x64.zip"
|
||||
if project.loveVersion >= ver'11.0.0' then
|
||||
bin = prefix..".zip"
|
||||
elseif project.loveVersion >= ver'0.9.0' then
|
||||
bin = prefix.."x-x64.zip"
|
||||
else
|
||||
bin = prefix.."ub.zip"
|
||||
bin = prefix.."x-ub.zip"
|
||||
end
|
||||
local url = "https://bitbucket.org/rude/love/downloads/"..bin
|
||||
local cache = utils.cache.."/"..bin
|
||||
@@ -78,7 +80,7 @@ function s.script(project)
|
||||
assert(ar:replace(infoPlistIndex, "string", infoPlist))
|
||||
ar:close()
|
||||
|
||||
os.rename(bin, project.title.."-macosx.zip")
|
||||
os.rename(bin, project.title.."-macos.zip")
|
||||
|
||||
fs.pop_dir()
|
||||
end
|
||||
|
@@ -3,10 +3,10 @@
|
||||
-- @usage windows(project)
|
||||
|
||||
local fs = require "luarocks.fs"
|
||||
local semver = require "semver"
|
||||
local zip = require "brimworks.zip"
|
||||
local Script = require "love-release.script"
|
||||
local utils = require "love-release.utils"
|
||||
local ver = utils.love.ver
|
||||
|
||||
local s = {}
|
||||
|
||||
@@ -14,7 +14,11 @@ local s = {}
|
||||
local function release(script, project, arch)
|
||||
local prefix = "love-"..tostring(project.loveVersion).."-win"
|
||||
local dir, bin
|
||||
if project.loveVersion >= semver'0.9.0' then
|
||||
if project.loveVersion.major == 11 then
|
||||
bin = prefix..arch..".zip"
|
||||
prefix = "love-"..tostring(project.loveVersion)..".0-win"
|
||||
dir = prefix..arch.."/"
|
||||
elseif project.loveVersion >= ver'0.9.0' then
|
||||
bin = prefix..arch..".zip"
|
||||
dir = prefix..arch.."/"
|
||||
else
|
||||
@@ -75,7 +79,7 @@ function s.script(project, arch)
|
||||
if arch == 32 then
|
||||
release(script, project, 32)
|
||||
end
|
||||
if arch == 64 and project.loveVersion >= semver'0.8.0' then
|
||||
if arch == 64 and project.loveVersion >= ver'0.8.0' then
|
||||
release(script, project, 64)
|
||||
end
|
||||
fs.pop_dir()
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
local cfg = require 'luarocks.cfg'
|
||||
local fs = require 'luarocks.fs'
|
||||
local semver = require 'semver'
|
||||
|
||||
local utils = {}
|
||||
|
||||
@@ -30,40 +29,75 @@ end
|
||||
|
||||
utils.love = {}
|
||||
|
||||
local ver = {
|
||||
major = nil,
|
||||
minor = nil,
|
||||
patch = nil,
|
||||
str = nil
|
||||
}
|
||||
utils.love.ver = ver
|
||||
|
||||
function ver:new(str)
|
||||
local major, minor, patch = str:match("^(%d+)%.?(%d*)%.?(%d*)$")
|
||||
assert(type(major) == 'string',
|
||||
("Could not extract version number(s) from %q"):format(str))
|
||||
local major, minor, patch = tonumber(major), tonumber(minor), tonumber(patch)
|
||||
local o = { major = major, minor = minor, patch = patch, str = str }
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
return o
|
||||
end
|
||||
|
||||
function ver:__eq(other)
|
||||
return self.major == other.major and self.minor == other.minor and
|
||||
self.patch == other.patch
|
||||
end
|
||||
|
||||
function ver:__lt(other)
|
||||
if self.major ~= other.major then return self.major < other.major end
|
||||
if self.minor ~= other.minor then return self.minor < other.minor end
|
||||
if self.patch ~= other.patch then return self.patch < other.patch end
|
||||
return false
|
||||
end
|
||||
|
||||
function ver:__tostring()
|
||||
local buffer = { ("%d.%d"):format(self.major, self.minor) }
|
||||
if self.patch then table.insert(buffer, "." .. self.patch) end
|
||||
return table.concat(buffer)
|
||||
end
|
||||
|
||||
setmetatable(ver, { __call = ver.new })
|
||||
|
||||
--- All supported LÖVE versions.
|
||||
-- @local
|
||||
utils.love.versionTable = {
|
||||
semver'11.0.0',
|
||||
semver'0.10.2', semver'0.10.1', semver'0.10.0',
|
||||
semver'0.9.2', semver'0.9.1', semver'0.9.0',
|
||||
semver'0.8.0',
|
||||
semver'0.7.2', semver'0.7.1', semver'0.7.0',
|
||||
semver'0.6.2', semver'0.6.1', semver'0.6.0',
|
||||
ver'11.1', ver'11.0',
|
||||
ver'0.10.2', ver'0.10.1', ver'0.10.0',
|
||||
ver'0.9.2', ver'0.9.1', ver'0.9.0',
|
||||
ver'0.8.0',
|
||||
ver'0.7.2', ver'0.7.1', ver'0.7.0',
|
||||
ver'0.6.2', ver'0.6.1', ver'0.6.0',
|
||||
--[[
|
||||
semver'0.5.0',
|
||||
semver'0.4.0',
|
||||
semver'0.3.2', semver'0.3.1', semver'0.3.0',
|
||||
semver'0.2.1', semver'0.2.0',
|
||||
semver'0.1.1',
|
||||
ver'0.5.0',
|
||||
ver'0.4.0',
|
||||
ver'0.3.2', ver'0.3.1', ver'0.3.0',
|
||||
ver'0.2.1', ver'0.2.0',
|
||||
ver'0.1.1',
|
||||
--]]
|
||||
}
|
||||
|
||||
--- Last script LÖVE version.
|
||||
function utils.love.lastVersion()
|
||||
return utils.love.versionTable[1]
|
||||
end
|
||||
utils.love.lastVersion = utils.love.versionTable[1]
|
||||
|
||||
--- First supported LÖVE version.
|
||||
function utils.love.minVersion()
|
||||
return utils.love.versionTable[#utils.love.versionTable]
|
||||
end
|
||||
utils.love.minVersion = utils.love.versionTable[#utils.love.versionTable]
|
||||
|
||||
--- Checks if a LÖVE version exists and is supported.
|
||||
-- @tparam semver version LÖVE version.
|
||||
-- @tparam ver version LÖVE version.
|
||||
-- @treturn bool true is the version is supported.
|
||||
function utils.love.isSupported(version)
|
||||
if version >= utils.love.minVersion()
|
||||
and version <= utils.love.lastVersion() then
|
||||
if version >= utils.love.minVersion
|
||||
and version <= utils.love.lastVersion then
|
||||
for _, v in ipairs(utils.love.versionTable) do
|
||||
if version == v then
|
||||
return true
|
||||
|
Reference in New Issue
Block a user