forked from xmake-io/xmake-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_artifacts.lua
60 lines (58 loc) · 2.17 KB
/
build_artifacts.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import("core.package.package")
import("core.base.semver")
import("packages")
function build_artifacts(name, versions)
local buildinfo = {name = name, versions = versions}
print(buildinfo)
os.tryrm("build-artifacts")
os.exec("git clone [email protected]: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
}
}
if ok then
break
end
trycount = trycount + 1
end
assert(trycount < 2)
os.cd(oldir)
end
function main()
local files = os.iorun("git diff --name-only HEAD^")
for _, file in ipairs(files:split('\n'), string.trim) do
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 = package.load_from_repository(packagename, nil, packagedir, file)
if instance and packages.is_supported(instance, "windows")
and (instance.is_headeronly and not instance:is_headeronly()) then
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))
end
end
end
end
end
end