Test
This commit is contained in:
59
.github/workflows/minify.yml
vendored
59
.github/workflows/minify.yml
vendored
@@ -32,28 +32,53 @@ jobs:
|
|||||||
echo "Creating minification script..."
|
echo "Creating minification script..."
|
||||||
cat > minify_script.lua << 'EOL'
|
cat > minify_script.lua << 'EOL'
|
||||||
local minify = loadfile("minify.lua")()
|
local minify = loadfile("minify.lua")()
|
||||||
local f = io.open("src/main.lua", "r")
|
local lfs = require("lfs")
|
||||||
local content = f:read("*all")
|
|
||||||
f:close()
|
|
||||||
|
|
||||||
local success, minified = minify(content)
|
local files = {}
|
||||||
|
for file in lfs.dir("src") do
|
||||||
if not success then
|
if file:match("%.lua$") then
|
||||||
print("Minification failed")
|
table.insert(files, file)
|
||||||
print(minified)
|
end
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local out = io.open("release/main.min.lua", "w")
|
local output = {
|
||||||
out:write(minified)
|
'local minified = true\n',
|
||||||
|
'local project = {}\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file in ipairs(files) do
|
||||||
|
local f = io.open("src/" .. file, "r")
|
||||||
|
local content = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
local success, minified = minify(content)
|
||||||
|
if not success then
|
||||||
|
print("Failed to minify " .. file)
|
||||||
|
print(minified)
|
||||||
|
os.exit(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(output, string.format(
|
||||||
|
'project["%s"] = function(...) %s end\n',
|
||||||
|
file, minified
|
||||||
|
))
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(output, 'return project["main.lua"]')
|
||||||
|
|
||||||
|
local out = io.open("release/project.min.lua", "w")
|
||||||
|
out:write(table.concat(output))
|
||||||
out:close()
|
out:close()
|
||||||
EOL
|
EOL
|
||||||
|
|
||||||
|
echo "Installing LuaFileSystem..."
|
||||||
|
sudo apt-get install -y lua-filesystem
|
||||||
|
|
||||||
echo "Running minification..."
|
echo "Running minification..."
|
||||||
if lua minify_script.lua; then
|
if lua minify_script.lua; then
|
||||||
echo "Minification successful"
|
echo "Minification successful"
|
||||||
echo "Minified content:"
|
echo "Minified content:"
|
||||||
cat release/main.min.lua
|
cat release/project.min.lua
|
||||||
else
|
else
|
||||||
echo "Minification failed"
|
echo "Minification failed"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -62,14 +87,14 @@ jobs:
|
|||||||
- name: Commit minified Lua file
|
- name: Commit minified Lua file
|
||||||
if: success()
|
if: success()
|
||||||
run: |
|
run: |
|
||||||
if [ -s release/main.min.lua ]; then
|
if [ -s release/project.min.lua ]; then
|
||||||
git config --global user.name 'github-actions[bot]'
|
git config --global user.name 'github-actions[bot]'
|
||||||
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||||
git add release/main.min.lua
|
git add release/project.min.lua
|
||||||
git commit -m 'Minify main.lua'
|
git commit -m 'Minify all Lua files into project bundle'
|
||||||
git push
|
git push
|
||||||
else
|
else
|
||||||
echo "Error: main.min.lua is empty or doesn't exist"
|
echo "Error: project.min.lua is empty or doesn't exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -112,6 +112,5 @@ function basalt.run(isActive)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
basalt.autoUpdate = basalt.run
|
|
||||||
|
|
||||||
return basalt
|
return basalt
|
||||||
Reference in New Issue
Block a user