From 701f1fbcba10e0700728dd466778defc784f164d Mon Sep 17 00:00:00 2001 From: Li Jin Date: Wed, 1 Nov 2023 10:15:25 +0800 Subject: add luarocks upload. [skip CI] --- spec/inputs/luarocks_upload.yue | 55 ++++++++++++++++++++++++++++++++++++++++ spec/outputs/luarocks_upload.lua | 28 ++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 spec/inputs/luarocks_upload.yue create mode 100644 spec/outputs/luarocks_upload.lua (limited to 'spec') diff --git a/spec/inputs/luarocks_upload.yue b/spec/inputs/luarocks_upload.yue new file mode 100644 index 0000000..30e8434 --- /dev/null +++ b/spec/inputs/luarocks_upload.yue @@ -0,0 +1,55 @@ +luarocksKey = ... +local version +with? io.open "src/yuescript/yue_compiler.cpp" + codes = \read "*a" + \close! + version = codes\match "const std::string_view version = \"(.-)\"sv;" +unless version? + print "failed to get version!" + os.exit 1 + +rockspec = "rockspec_format = '3.0' +package = 'Yuescript' +version = '#{version}-1' +source = { + url = 'git+https://github.com/pigpigyyy/yuescript' +} +description = { + summary = 'Yuescript is a Moonscript dialect.', + detailed = [[ + Yuescript is a Moonscript dialect. It is derived from Moonscript language 0.5.0 and continuously adopting new features to be more up to date. ]], + homepage = 'https://github.com/pigpigyyy/yuescript', + maintainer = 'Li Jin ', + labels = {'yuescript','cpp','transpiler','moonscript'}, + license = 'MIT' +} +dependencies = { + 'lua >= 5.1', +} +build = { + type = 'cmake', + variables = { + LUA='$(LUA)', + LUA_INCDIR='$(LUA_INCDIR)', + CMAKE_BUILD_TYPE='Release' + }, + install = { + lib = { + 'build.luarocks/yue.so' + }, + bin = { + 'build.luarocks/yue' + } + } +}" + +specFile = "yuescript-#{version}-1.rockspec" +with? io.open specFile, "w+" + \write rockspec + \close! + +result = io.popen("luarocks upload --api-key #{luarocksKey} #{specFile}")\read '*a' +unless result\match "Done:" + print result + os.exit 1 + diff --git a/spec/outputs/luarocks_upload.lua b/spec/outputs/luarocks_upload.lua new file mode 100644 index 0000000..96988d7 --- /dev/null +++ b/spec/outputs/luarocks_upload.lua @@ -0,0 +1,28 @@ +local luarocksKey = ... +local version +do + local _with_0 = io.open("src/yuescript/yue_compiler.cpp") + if _with_0 ~= nil then + local codes = _with_0:read("*a") + _with_0:close() + version = codes:match("const std::string_view version = \"(.-)\"sv;") + end +end +if not (version ~= nil) then + print("failed to get version!") + os.exit(1) +end +local rockspec = "rockspec_format = '3.0'\npackage = 'Yuescript'\nversion = '" .. tostring(version) .. "-1'\nsource = {\n url = 'git+https://github.com/pigpigyyy/yuescript'\n}\ndescription = {\n summary = 'Yuescript is a Moonscript dialect.',\n detailed = [[\n Yuescript is a Moonscript dialect. It is derived from Moonscript language 0.5.0 and continuously adopting new features to be more up to date. ]],\n homepage = 'https://github.com/pigpigyyy/yuescript',\n maintainer = 'Li Jin ',\n labels = {'yuescript','cpp','transpiler','moonscript'},\n license = 'MIT'\n}\ndependencies = {\n 'lua >= 5.1',\n}\nbuild = {\n type = 'cmake',\n variables = {\n LUA='$(LUA)',\n LUA_INCDIR='$(LUA_INCDIR)',\n CMAKE_BUILD_TYPE='Release'\n },\n install = {\n lib = {\n 'build.luarocks/yue.so'\n },\n bin = {\n 'build.luarocks/yue'\n }\n }\n}" +local specFile = "yuescript-" .. tostring(version) .. "-1.rockspec" +do + local _with_0 = io.open(specFile, "w+") + if _with_0 ~= nil then + _with_0:write(rockspec) + _with_0:close() + end +end +local result = io.popen("luarocks upload --api-key " .. tostring(luarocksKey) .. " " .. tostring(specFile)):read('*a') +if not result:match("Done:") then + print(result) + return os.exit(1) +end -- cgit v1.2.3-55-g6feb