premake/scripts/release.lua

114 lines
2.1 KiB
Lua
Raw Normal View History

2009-07-16 15:20:15 +00:00
--
-- Merge the current working branch to Premake's release branch,
-- update the embedded version number and tag the result.
--
2009-12-09 21:03:29 +00:00
--
-- Helper function: run a command while hiding its output.
2009-12-09 21:03:29 +00:00
--
local function execQuiet(cmd, ...)
cmd = string.format(cmd, unpack(arg)) .. " > _output_.log 2> _error_.log"
local z = os.execute(cmd)
os.remove("_output_.log")
os.remove("_error_.log")
2009-12-09 21:03:29 +00:00
return z
end
2009-07-16 15:20:15 +00:00
--
-- Check the command line arguments, and show some help if needed.
2009-07-16 15:20:15 +00:00
--
local usage = 'usage is: release <version>\n' ..
' <version> is of the form "5.0", "5.0.1", or "5.0-rc1"\n'
local usage = 'usage is: release <version>\n'
if #_ARGS ~= 1 then
error(usage, 0)
2009-07-16 15:20:15 +00:00
end
2009-12-09 21:03:29 +00:00
local version = _ARGS[1]
2009-12-05 18:00:46 +00:00
2009-07-16 15:20:15 +00:00
--
-- Make sure I've got what I've need to be happy.
2009-07-16 15:20:15 +00:00
--
local required = { "hg" }
2009-12-09 21:03:29 +00:00
for _, value in ipairs(required) do
local z = execQuiet("%s --version", value)
2009-12-05 18:00:46 +00:00
if z ~= 0 then
error("required tool '" .. value .. "' not found", 0)
2009-12-05 18:00:46 +00:00
end
end
2009-07-16 15:20:15 +00:00
--
-- Figure out what I'm doing.
2009-07-16 15:20:15 +00:00
--
os.chdir("..")
local branch = os.outputof("hg branch"):gsub("%s+$", "")
2010-08-11 18:33:14 +00:00
2009-12-05 18:00:46 +00:00
--
-- Make sure I'm sure.
2009-07-16 15:20:15 +00:00
--
printf("")
printf("I am about to")
printf(" ...merge %s to the release branch", branchName)
printf(" ...update the embedded version to \"%s\"", version)
printf(" ...commit and tag the merged result")
printf("")
printf("Does this look right to you? If so, press [Enter] to begin.")
io.read()
2009-07-16 15:20:15 +00:00
--
-- Pull down the release branch.
2009-07-16 15:20:15 +00:00
--
print("Preparing release folder")
2010-11-03 00:17:01 +00:00
os.mkdir("release")
os.chdir("release")
os.rmdir(version)
print("Cloning source code")
local z = os.executef("hg clone .. -r release %s", branch, version)
2010-11-03 00:17:01 +00:00
if z ~= 0 then
error("clone failed", 0)
2010-11-03 00:17:01 +00:00
end
--
-- Merge in the release working branch.
--
error("merge of release working branch is not yet implemented")
2009-12-05 18:00:46 +00:00
2009-07-16 15:20:15 +00:00
--
2009-12-05 18:00:46 +00:00
-- Update the version number in premake.c
2009-07-16 15:20:15 +00:00
--
2009-12-05 18:00:46 +00:00
print("Updating version number...")
2009-12-09 21:03:29 +00:00
os.chdir(version)
2010-08-11 18:33:14 +00:00
io.input("src/host/premake.c")
local text = io.read("*a")
text = text:gsub("HEAD", version)
io.output("src/host/premake.c")
io.write(text)
io.close()
2009-12-05 18:00:46 +00:00
2009-07-16 15:20:15 +00:00
--
-- Commit and tag merged revision.
2009-07-16 15:20:15 +00:00
--
error("commit and tag of merged branch is not yet implemented")