Skip to content

Commit 50e0224

Browse files
committed
fix releases
1 parent 20f208b commit 50e0224

File tree

2 files changed

+78
-78
lines changed

2 files changed

+78
-78
lines changed

tools/build.lua

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
local plugins = fs.read_dir("src", { recurse = false, as_dir_entries = false, return_full_paths = true })
2-
3-
local OUTPUT_DIRECTORY = "build"
4-
5-
for _, plugin in ipairs(plugins) do
6-
if fs.file_type(plugin --[[@as string]]) ~= "directory" then
7-
goto CONTINUE
8-
end
9-
local plugin_name = path.nameext(plugin)
10-
local version = fs.read_file(path.combine(plugin, "VERSION"))
11-
12-
local file_name = string.interpolate("${plugin_name}-${version}.zip", { plugin_name = plugin_name, version = version })
13-
zip.compress(plugin .. "/", path.combine(OUTPUT_DIRECTORY, file_name), { recurse = true, content_only = true, overwrite = true })
14-
::CONTINUE::
15-
end
16-
1+
local plugins = fs.read_dir("src", { recurse = false, as_dir_entries = false, return_full_paths = true })
2+
3+
local OUTPUT_DIRECTORY = "build"
4+
5+
for _, plugin in ipairs(plugins) do
6+
if fs.file_type(plugin --[[@as string]]) ~= "directory" then
7+
goto CONTINUE
8+
end
9+
local plugin_name = path.nameext(plugin)
10+
local version = fs.read_file(path.combine(plugin, "VERSION"))
11+
12+
local file_name = string.interpolate("${plugin_name}-${version}.zip", { plugin_name = plugin_name, version = version })
13+
zip.compress(plugin .. "/", path.combine(OUTPUT_DIRECTORY, file_name), { recurse = true, content_only = true, overwrite = true })
14+
::CONTINUE::
15+
end
16+

tools/check-release-required.lua

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
local built_plugins = fs.read_dir("build", { recurse = false, as_dir_entries = false, return_full_paths = false }) --[=[@as string[]]=]
2-
3-
local release_id = os.getenv("RELEASE_ID")
4-
if not release_id then
5-
error("RELEASE_ID is not set!")
6-
end
7-
8-
local to_be_released = {}
9-
-- https://air.alis.is/ami/plugin/platform/v/0.2.0.json
10-
local client = net.RestClient:new("https://air.alis.is/ami/plugin/")
11-
12-
for _, plugin in ipairs(built_plugins) do
13-
if fs.file_type(path.combine("build", plugin)) ~= "file" or plugin == ".gitkeep" then
14-
goto CONTINUE
15-
end
16-
local plugin_name, version = string.match(plugin, "^(.+)-(.+)%.zip$")
17-
if not plugin_name or not version then
18-
goto CONTINUE
19-
end
20-
local ok, response = client:safe_get(plugin_name .. "/v/" .. version .. ".json", { follow_redirects = true})
21-
if ok and response.code == 200 then goto CONTINUE end
22-
23-
table.insert(to_be_released,
24-
{ plugin_name = plugin_name, version = version, sha256 = fs.hash_file(path.combine("build", plugin),
25-
{ hex = true, type = "sha256" }) })
26-
27-
::CONTINUE::
28-
end
29-
30-
if #to_be_released == 0 then
31-
io.write("")
32-
return
33-
end
34-
35-
-- air supports coma separated packages
36-
-- plugins require `plugin:` prefix
37-
local ids = string.join(",", table.map(to_be_released, function(item) return "plugin:" .. item.plugin_name end))
38-
-- https://github.com/alis-is/ami-plugins/releases/download/<release_id>/<plugin_name>-<version>.zip
39-
local sources = string.join(",", table.map(to_be_released, function(item)
40-
local msg = string.interpolate(
41-
"https://github.com/alis-is/ami-plugins/releases/download/${release_id}/${plugin_name}-${version}.zip", {
42-
release_id = release_id,
43-
plugin_name = item.plugin_name,
44-
version = item.version
45-
})
46-
return msg
47-
end))
48-
local versions = string.join(",", table.map(to_be_released, function(item) return item.version end))
49-
local hashes = string.join(",", table.map(to_be_released, function(item) return item.sha256 end))
50-
51-
local REPOSITORY = os.getenv("GITHUB_REPOSITORY")
52-
53-
local payload = string.interpolate(
54-
'{ "id": "${ids}", "repository": "${repository}", "version": "${versions}", "package": "${packages}", "sha256": "${hashes}"}',
55-
{
56-
ids = ids,
57-
versions = versions,
58-
packages = sources,
59-
hashes = hashes,
60-
repository = REPOSITORY
61-
})
62-
1+
local built_plugins = fs.read_dir("build", { recurse = false, as_dir_entries = false, return_full_paths = false }) --[=[@as string[]]=]
2+
3+
local release_id = os.getenv("RELEASE_ID")
4+
if not release_id then
5+
error("RELEASE_ID is not set!")
6+
end
7+
8+
local to_be_released = {}
9+
-- https://air.alis.is/ami/plugin/platform/v/0.2.0.json
10+
local client = net.RestClient:new("https://air.alis.is/ami/plugin/")
11+
12+
for _, plugin in ipairs(built_plugins) do
13+
if fs.file_type(path.combine("build", plugin)) ~= "file" or plugin == ".gitkeep" then
14+
goto CONTINUE
15+
end
16+
local plugin_name, version = string.match(plugin, "^(.+)-(.+)%.zip$")
17+
if not plugin_name or not version then
18+
goto CONTINUE
19+
end
20+
local response, err = client:get(plugin_name .. "/v/" .. version .. ".json", { follow_redirects = true})
21+
if response and response.code == 200 then goto CONTINUE end
22+
table.insert(to_be_released,
23+
{ plugin_name = plugin_name, version = version, sha256 = fs.hash_file(path.combine("build", plugin),
24+
{ hex = true, type = "sha256" }) })
25+
26+
::CONTINUE::
27+
end
28+
29+
print("Plugins to be released: " .. #to_be_released)
30+
if #to_be_released == 0 then
31+
io.write("")
32+
return
33+
end
34+
35+
-- air supports coma separated packages
36+
-- plugins require `plugin:` prefix
37+
local ids = string.join(",", table.map(to_be_released, function(item) return "plugin:" .. item.plugin_name end))
38+
-- https://github.com/alis-is/ami-plugins/releases/download/<release_id>/<plugin_name>-<version>.zip
39+
local sources = string.join(",", table.map(to_be_released, function(item)
40+
local msg = string.interpolate(
41+
"https://github.com/alis-is/ami-plugins/releases/download/${release_id}/${plugin_name}-${version}.zip", {
42+
release_id = release_id,
43+
plugin_name = item.plugin_name,
44+
version = item.version
45+
})
46+
return msg
47+
end))
48+
local versions = string.join(",", table.map(to_be_released, function(item) return item.version end))
49+
local hashes = string.join(",", table.map(to_be_released, function(item) return item.sha256 end))
50+
51+
local REPOSITORY = os.getenv("GITHUB_REPOSITORY")
52+
53+
local payload = string.interpolate(
54+
'{ "id": "${ids}", "repository": "${repository}", "version": "${versions}", "package": "${packages}", "sha256": "${hashes}"}',
55+
{
56+
ids = ids,
57+
versions = versions,
58+
packages = sources,
59+
hashes = hashes,
60+
repository = REPOSITORY
61+
})
62+
6363
io.write(payload)

0 commit comments

Comments
 (0)