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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
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
-- ==============================
-- 1. Prepare minimal source tree
-- ==============================
local tmpBase = os.getenv("RUNNER_TEMP") or os.getenv("TMPDIR") or "/tmp"
local pkgRoot = "#{tmpBase}/yuescript_pack_#{version}"
local srcDir = "#{pkgRoot}/yuescript-#{version}"
local tarFile = "#{pkgRoot}/yuescript-#{version}.tar.gz"
run = (cmd) ->
print cmd
ok = os.execute cmd
unless ok == true or ok == 0
print "Command failed!"
os.exit 1
-- clean & create
run "rm -rf '#{pkgRoot}'"
run "mkdir -p '#{srcDir}'"
-- copy whitelist files
run "cp CMakeLists.txt '#{srcDir}/'"
run "cp README.md '#{srcDir}/'"
run "cp LICENSE '#{srcDir}/'"
run "cp -R src '#{srcDir}/'"
-- create tar.gz
run "tar -C '#{pkgRoot}' -czf '#{tarFile}' 'yuescript-#{version}'"
local sourceUrl = "file://#{tarFile}"
-- =========================
-- 2. Generate rockspec
-- =========================
rockspec = "rockspec_format = '3.0'
package = 'Yuescript'
version = '#{version}-1'
source = {
url = '#{sourceUrl}'
}
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/IppClub/YueScript',
maintainer = 'Li Jin <dragon-fly@qq.com>',
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'
}
},
platforms = {
windows = {
install = {
lib = {
'build.luarocks/Release/yue.dll'
},
bin = {
'build.luarocks/Release/yue.exe'
}
}
}
}
}"
specFile = "yuescript-#{version}-1.rockspec"
with? io.open specFile, "w+"
\write rockspec
\close!
print "Using source: #{sourceUrl}"
print "Uploading rockspec: #{specFile}"
-- =========================
-- 3. Upload
-- =========================
result = io.popen("luarocks upload --api-key #{luarocksKey} #{specFile}")\read '*a'
unless result\match "Done:"
print result
os.exit 1
|