|
|
@ -14,22 +14,24 @@ function _load_package(packagename, packagedir, packagefile) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function _get_all_packages() |
|
|
|
function _get_all_packages(pattern) |
|
|
|
local packages = _g.packages |
|
|
|
local packages = _g.packages |
|
|
|
if not packages then |
|
|
|
if not packages then |
|
|
|
packages = {} |
|
|
|
packages = {} |
|
|
|
for _, packagedir in ipairs(os.dirs(path.join("packages", "*", "*"))) do |
|
|
|
for _, packagedir in ipairs(os.dirs(path.join("packages", "*", "*"))) do |
|
|
|
local packagename = path.filename(packagedir) |
|
|
|
local packagename = path.filename(packagedir) |
|
|
|
local packagefile = path.join(packagedir, "xmake.lua") |
|
|
|
if not pattern or packagename:match(pattern) then |
|
|
|
local instance = _load_package(packagename, packagedir, packagefile) |
|
|
|
local packagefile = path.join(packagedir, "xmake.lua") |
|
|
|
local basename = instance:get("base") |
|
|
|
local instance = _load_package(packagename, packagedir, packagefile) |
|
|
|
if instance and basename then |
|
|
|
local basename = instance:get("base") |
|
|
|
local basedir = path.join("packages", basename:sub(1, 1):lower(), basename:lower()) |
|
|
|
if instance and basename then |
|
|
|
local basefile = path.join(basedir, "xmake.lua") |
|
|
|
local basedir = path.join("packages", basename:sub(1, 1):lower(), basename:lower()) |
|
|
|
instance._BASE = _load_package(basename, basedir, basefile) |
|
|
|
local basefile = path.join(basedir, "xmake.lua") |
|
|
|
end |
|
|
|
instance._BASE = _load_package(basename, basedir, basefile) |
|
|
|
if instance then |
|
|
|
end |
|
|
|
table.insert(packages, instance) |
|
|
|
if instance then |
|
|
|
|
|
|
|
table.insert(packages, instance) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
_g.packages = packages |
|
|
|
_g.packages = packages |
|
|
@ -82,33 +84,40 @@ function _update_version(instance, version, shasum) |
|
|
|
instance:name(), version_current, version) |
|
|
|
instance:name(), version_current, version) |
|
|
|
os.vexec("git add .") |
|
|
|
os.vexec("git add .") |
|
|
|
os.vexec("git commit -a -m \"Update %s to %s\"", instance:name(), version) |
|
|
|
os.vexec("git commit -a -m \"Update %s to %s\"", instance:name(), version) |
|
|
|
os.vexec("git push %s %s:%s", repourl, branch, branch) |
|
|
|
--os.vexec("git push %s %s:%s", repourl, branch, branch) |
|
|
|
os.vexec("gh pr create --label \"auto-update\" --title \"Auto-update %s to %s\" --body \"%s\" -R xmake-io/xmake-repo -B dev -H %s", |
|
|
|
--os.vexec("gh pr create --label \"auto-update\" --title \"Auto-update %s to %s\" --body \"%s\" -R xmake-io/xmake-repo -B dev -H %s", |
|
|
|
instance:name(), version, body, branch) |
|
|
|
-- instance:name(), version, body, branch) |
|
|
|
end |
|
|
|
end |
|
|
|
os.vexec("git reset --hard HEAD") |
|
|
|
os.vexec("git reset --hard HEAD") |
|
|
|
os.vexec("git checkout %s", branch_current) |
|
|
|
os.vexec("git checkout %s", branch_current) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function main(maxcount) |
|
|
|
function main(pattern) |
|
|
|
local count = 0 |
|
|
|
local count = 0 |
|
|
|
local maxcount = tonumber(maxcount or 10) |
|
|
|
local maxcount = 3 |
|
|
|
local instances = _get_all_packages() |
|
|
|
local instances = _get_all_packages(pattern) |
|
|
|
math.randomseed(os.time()) |
|
|
|
math.randomseed(os.time()) |
|
|
|
while count < maxcount do |
|
|
|
while count < maxcount and #instances > 0 do |
|
|
|
local instance = instances[math.random(#instances)] |
|
|
|
local idx = math.random(#instances) |
|
|
|
|
|
|
|
local instance = instances[idx] |
|
|
|
local checkupdate_filepath = path.join(instance:scriptdir(), "checkupdate.lua") |
|
|
|
local checkupdate_filepath = path.join(instance:scriptdir(), "checkupdate.lua") |
|
|
|
if not os.isfile(checkupdate_filepath) then |
|
|
|
if not os.isfile(checkupdate_filepath) then |
|
|
|
checkupdate_filepath = path.join(os.scriptdir(), "checkupdate.lua") |
|
|
|
checkupdate_filepath = path.join(os.scriptdir(), "checkupdate.lua") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
local updated = false |
|
|
|
if os.isfile(checkupdate_filepath) then |
|
|
|
if os.isfile(checkupdate_filepath) then |
|
|
|
local checkupdate = import("checkupdate", {rootdir = path.directory(checkupdate_filepath), anonymous = true}) |
|
|
|
local checkupdate = import("checkupdate", {rootdir = path.directory(checkupdate_filepath), anonymous = true}) |
|
|
|
local version, shasum = checkupdate(instance) |
|
|
|
local version, shasum = checkupdate(instance) |
|
|
|
if version and shasum and not _is_pending(instance, version) then |
|
|
|
if version and shasum and not _is_pending(instance, version) then |
|
|
|
cprint("package(%s): new version ${bright}%s${clear} found, shasum: ${bright}%s", instance:name(), version, shasum) |
|
|
|
cprint("package(%s): new version ${bright}%s${clear} found, shasum: ${bright}%s", instance:name(), version, shasum) |
|
|
|
_update_version(instance, version, shasum) |
|
|
|
_update_version(instance, version, shasum) |
|
|
|
count = count + 1 |
|
|
|
updated = true |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
if updated then |
|
|
|
|
|
|
|
count = count + 1 |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
table.remove(instances, idx) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|