diff options
| author | Li Jin <dragon-fly@qq.com> | 2023-11-01 10:15:25 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2023-11-01 10:15:25 +0800 |
| commit | 701f1fbcba10e0700728dd466778defc784f164d (patch) | |
| tree | 666e472a824e3f9a21eaae710977704750fab664 | |
| parent | d092bafc74a851939925ec2d40a8bd364b607d68 (diff) | |
| download | yuescript-701f1fbcba10e0700728dd466778defc784f164d.tar.gz yuescript-701f1fbcba10e0700728dd466778defc784f164d.tar.bz2 yuescript-701f1fbcba10e0700728dd466778defc784f164d.zip | |
add luarocks upload. [skip CI]
Diffstat (limited to '')
| -rw-r--r-- | spec/inputs/luarocks_upload.yue | 55 | ||||
| -rw-r--r-- | spec/outputs/luarocks_upload.lua | 28 |
2 files changed, 83 insertions, 0 deletions
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 @@ | |||
| 1 | luarocksKey = ... | ||
| 2 | local version | ||
| 3 | with? io.open "src/yuescript/yue_compiler.cpp" | ||
| 4 | codes = \read "*a" | ||
| 5 | \close! | ||
| 6 | version = codes\match "const std::string_view version = \"(.-)\"sv;" | ||
| 7 | unless version? | ||
| 8 | print "failed to get version!" | ||
| 9 | os.exit 1 | ||
| 10 | |||
| 11 | rockspec = "rockspec_format = '3.0' | ||
| 12 | package = 'Yuescript' | ||
| 13 | version = '#{version}-1' | ||
| 14 | source = { | ||
| 15 | url = 'git+https://github.com/pigpigyyy/yuescript' | ||
| 16 | } | ||
| 17 | description = { | ||
| 18 | summary = 'Yuescript is a Moonscript dialect.', | ||
| 19 | detailed = [[ | ||
| 20 | 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. ]], | ||
| 21 | homepage = 'https://github.com/pigpigyyy/yuescript', | ||
| 22 | maintainer = 'Li Jin <dragon-fly@qq.com>', | ||
| 23 | labels = {'yuescript','cpp','transpiler','moonscript'}, | ||
| 24 | license = 'MIT' | ||
| 25 | } | ||
| 26 | dependencies = { | ||
| 27 | 'lua >= 5.1', | ||
| 28 | } | ||
| 29 | build = { | ||
| 30 | type = 'cmake', | ||
| 31 | variables = { | ||
| 32 | LUA='$(LUA)', | ||
| 33 | LUA_INCDIR='$(LUA_INCDIR)', | ||
| 34 | CMAKE_BUILD_TYPE='Release' | ||
| 35 | }, | ||
| 36 | install = { | ||
| 37 | lib = { | ||
| 38 | 'build.luarocks/yue.so' | ||
| 39 | }, | ||
| 40 | bin = { | ||
| 41 | 'build.luarocks/yue' | ||
| 42 | } | ||
| 43 | } | ||
| 44 | }" | ||
| 45 | |||
| 46 | specFile = "yuescript-#{version}-1.rockspec" | ||
| 47 | with? io.open specFile, "w+" | ||
| 48 | \write rockspec | ||
| 49 | \close! | ||
| 50 | |||
| 51 | result = io.popen("luarocks upload --api-key #{luarocksKey} #{specFile}")\read '*a' | ||
| 52 | unless result\match "Done:" | ||
| 53 | print result | ||
| 54 | os.exit 1 | ||
| 55 | |||
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 @@ | |||
| 1 | local luarocksKey = ... | ||
| 2 | local version | ||
| 3 | do | ||
| 4 | local _with_0 = io.open("src/yuescript/yue_compiler.cpp") | ||
| 5 | if _with_0 ~= nil then | ||
| 6 | local codes = _with_0:read("*a") | ||
| 7 | _with_0:close() | ||
| 8 | version = codes:match("const std::string_view version = \"(.-)\"sv;") | ||
| 9 | end | ||
| 10 | end | ||
| 11 | if not (version ~= nil) then | ||
| 12 | print("failed to get version!") | ||
| 13 | os.exit(1) | ||
| 14 | end | ||
| 15 | 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 <dragon-fly@qq.com>',\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}" | ||
| 16 | local specFile = "yuescript-" .. tostring(version) .. "-1.rockspec" | ||
| 17 | do | ||
| 18 | local _with_0 = io.open(specFile, "w+") | ||
| 19 | if _with_0 ~= nil then | ||
| 20 | _with_0:write(rockspec) | ||
| 21 | _with_0:close() | ||
| 22 | end | ||
| 23 | end | ||
| 24 | local result = io.popen("luarocks upload --api-key " .. tostring(luarocksKey) .. " " .. tostring(specFile)):read('*a') | ||
| 25 | if not result:match("Done:") then | ||
| 26 | print(result) | ||
| 27 | return os.exit(1) | ||
| 28 | end | ||
