-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.lua
More file actions
88 lines (75 loc) · 2.64 KB
/
Copy pathproject.lua
File metadata and controls
88 lines (75 loc) · 2.64 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
local path = require("path")
local toml = require("toml")
local tblext = require("tblext")
require("tools")
project_dir("docs")
-- Example projects
local example_test_dirs = path.glob("examples/*/tests", { include_files = false })
for i, d in ipairs(example_test_dirs) do
if path.is_file(path.join(d, "project.lua")) then
project_dir(d)
end
end
task {
name = "find_cobble_source_files",
actions = { function (c) return { files = path.glob("src/**/*.*") } end },
deps = { dirs = { "src" } }
}
task {
name = "calc_build_dep",
actions = { function (c)
return { tasks = { (c.vars.cobble.build == "release" and "build_release") or "build_debug" } }
end },
deps = { vars = { "cobble.build" } }
}
task {
name = "build_release",
actions = { { tool = "cargo", "build", "--release", "--color", "always" } },
deps = { calc = { "find_cobble_source_files" } },
artifacts = { files = { "target/release/cobl" .. (PLATFORM.os_family == "windows" and ".exe" or "") } }
}
if PLATFORM.os_family == "windows" then
task {
name = "build_release_linux",
actions = { { tool = "wsl", "--shell-type", "login", "--", "cargo", "build", "--release" } },
deps = { calc = { "find_cobble_source_files" } },
artifacts = { files = { "target/release/cobl" } }
}
end
task {
name = "build_debug",
actions = { { tool = "cargo", "build", "--color", "always" } },
deps = { calc = { "find_cobble_source_files" } },
artifacts = { files = { "target/debug/cobl" .. (PLATFORM.os_family == "windows" and ".exe" or "") } }
}
task {
name = "build",
actions = {},
deps = { calc = { "calc_build_dep" } }
}
--------- Tasks for managing release automation -----------
local noop = function () end
task {
name = "version_tag",
output = "always",
always_run = true,
actions = {
{
tool = "git",
function (c)
local cargo_toml = toml.load("Cargo.toml")
local version_tag = "v" .. cargo_toml["package"]["version"]
c.println("Verison tag from Cargo.toml: " .. version_tag)
c.println("Getting latest version tag...")
local version_tag_exists, cmd_result = pcall(c.tool.git, { out=noop, err=noop, "rev-parse", version_tag })
if not version_tag_exists then
c.println("Creating and pushing tag: " .. version_tag)
c.tool.git { "tag", version_tag }
c.tool.git { "push", "origin", version_tag }
else
c.println("Tag " .. version_tag .. " already exists.")
end
end
}
}
}