package An official xmake package repository https://xrepo.xmake.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
4.2 KiB

4 years ago
import("core.package.package")
import("core.base.semver")
import("packages")
-- load package
function _load_package(packagename, packagedir, packagefile)
local funcinfo = debug.getinfo(package.load_from_repository)
if funcinfo and funcinfo.nparams == 3 then -- >= 2.7.8
return package.load_from_repository(packagename, packagedir, {packagefile = packagefile})
else
-- deprecated
return package.load_from_repository(packagename, nil, packagedir, packagefile)
end
end
function _build_artifacts(name, versions)
4 years ago
local buildinfo = {name = name, versions = versions}
print(buildinfo)
os.tryrm("build-artifacts")
4 years ago
os.exec("git clone git@github.com:xmake-mirror/build-artifacts.git -b build")
local oldir = os.cd("build-artifacts")
local trycount = 0
while trycount < 2 do
local ok = try
{
function ()
io.save("build.txt", buildinfo)
os.exec("git add -A")
os.exec("git commit -a -m \"autobuild %s by xmake-repo/ci\"", name)
os.exec("git push origin build")
return true
end,
catch
{
function ()
os.exec("git reset --hard HEAD^")
os.exec("git pull origin build")
end
}
}
4 years ago
if ok then
break
end
trycount = trycount + 1
end
assert(trycount < 2)
os.cd(oldir)
end
function _get_latest_modified_packages()
local instances = {}
4 years ago
local files = os.iorun("git diff --name-only HEAD^")
for _, file in ipairs(files:split('\n')) do
file = file:trim()
if file:find("packages", 1, true) and path.filename(file) == "xmake.lua" then
4 years ago
assert(file == file:lower(), "%s must be lower case!", file)
local packagedir = path.directory(file)
local packagename = path.filename(packagedir)
if #path.filename(path.directory(packagedir)) == 1 then
local instance = _load_package(packagename, packagedir, file)
if instance and packages.is_supported(instance, "windows")
and (instance.is_headeronly and not instance:is_headeronly()) then
table.insert(instances, instance)
end
end
end
end
return instances
end
function _get_packagedeps_in_latest_24h()
local instances = {}
local list = os.iorun("git log --since=\"24 hours ago\" --oneline")
local lines = list:split('\n')
if #lines > 0 then
local line = lines[#lines]
local commit = line:split(" ")[1]
if commit and #commit == 8 then
local files = os.iorun("git diff --name-only " .. commit .. "^")
print(files)
for _, file in ipairs(files:split('\n')) do
file = file:trim()
if file:find("packages", 1, true) and path.filename(file) == "xmake.lua" then
assert(file == file:lower(), "%s must be lower case!", file)
local packagedir = path.directory(file)
local packagename = path.filename(packagedir)
if #path.filename(path.directory(packagedir)) == 1 then
local instance = _load_package(packagename, packagedir, file)
if instance and packages.is_supported(instance, "windows")
and (instance.is_headeronly and not instance:is_headeronly()) then
table.insert(instances, instance)
end
end
4 years ago
end
end
end
end
for _, instance in ipairs(instances) do
print(instance:name())
end
end
function main()
--_get_packagedeps_in_latest_24h()
local instances = _get_latest_modified_packages()
for _, instance in ipairs(instances) do
local versions = instance:versions()
if versions and #versions > 0 then
table.sort(versions, function (a, b) return semver.compare(a, b) > 0 end)
local version_latest = versions[1]
_build_artifacts(instance:name(), table.wrap(version_latest))
4 years ago
end
end
end