2009-07-16 15:20:15 +00:00
|
|
|
--
|
2015-02-23 00:02:09 +00:00
|
|
|
-- Merge the current working branch to Premake's release branch,
|
|
|
|
-- update the embedded version number and tag the result.
|
2013-09-10 20:24:39 +00:00
|
|
|
--
|
2009-12-09 21:03:29 +00:00
|
|
|
|
|
|
|
|
2013-09-10 20:24:39 +00:00
|
|
|
--
|
2015-02-23 00:02:09 +00:00
|
|
|
-- Helper function: run a command while hiding its output.
|
2009-12-09 21:03:29 +00:00
|
|
|
--
|
|
|
|
|
2015-02-23 00:02:09 +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
|
|
|
--
|
2015-02-23 00:02:09 +00:00
|
|
|
-- Check the command line arguments, and show some help if needed.
|
2009-07-16 15:20:15 +00:00
|
|
|
--
|
|
|
|
|
2015-02-23 00:02:09 +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
|
2013-09-10 20:24:39 +00:00
|
|
|
|
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
|
|
|
--
|
2015-02-23 00:02:09 +00:00
|
|
|
-- Make sure I've got what I've need to be happy.
|
2009-07-16 15:20:15 +00:00
|
|
|
--
|
|
|
|
|
2015-02-23 00:02:09 +00:00
|
|
|
local required = { "hg" }
|
2009-12-09 21:03:29 +00:00
|
|
|
for _, value in ipairs(required) do
|
2015-02-23 00:02:09 +00:00
|
|
|
local z = execQuiet("%s --version", value)
|
2009-12-05 18:00:46 +00:00
|
|
|
if z ~= 0 then
|
2015-02-23 00:02:09 +00:00
|
|
|
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
|
|
|
|
|
|
|
--
|
2015-02-23 00:02:09 +00:00
|
|
|
-- Figure out what I'm doing.
|
2009-07-16 15:20:15 +00:00
|
|
|
--
|
|
|
|
|
2015-02-23 00:02:09 +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
|
|
|
--
|
2015-02-23 00:02:09 +00:00
|
|
|
-- Make sure I'm sure.
|
2009-07-16 15:20:15 +00:00
|
|
|
--
|
2015-02-23 00:02:09 +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
|
|
|
|
2013-09-10 20:24:39 +00:00
|
|
|
--
|
2015-02-23 00:02:09 +00:00
|
|
|
-- Pull down the release branch.
|
2009-07-16 15:20:15 +00:00
|
|
|
--
|
|
|
|
|
2015-02-23 00:02:09 +00:00
|
|
|
print("Preparing release folder")
|
2013-09-10 20:24:39 +00:00
|
|
|
|
2010-11-03 00:17:01 +00:00
|
|
|
os.mkdir("release")
|
2010-10-04 10:43:19 +00:00
|
|
|
os.chdir("release")
|
2015-02-23 00:02:09 +00:00
|
|
|
os.rmdir(version)
|
2013-09-10 20:24:39 +00:00
|
|
|
|
2015-02-23 00:02:09 +00:00
|
|
|
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
|
2015-02-23 00:02:09 +00:00
|
|
|
error("clone failed", 0)
|
2010-11-03 00:17:01 +00:00
|
|
|
end
|
2013-09-10 20:24:39 +00:00
|
|
|
|
2015-02-23 00:02:09 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- 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
|
|
|
|
2015-02-23 00:02:09 +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
|
|
|
|
|
|
|
--
|
2015-02-23 00:02:09 +00:00
|
|
|
-- Commit and tag merged revision.
|
2009-07-16 15:20:15 +00:00
|
|
|
--
|
|
|
|
|
2015-02-23 00:02:09 +00:00
|
|
|
error("commit and tag of merged branch is not yet implemented")
|