Test
This commit is contained in:
10
.github/workflows/docs.yml
vendored
10
.github/workflows/docs.yml
vendored
@@ -42,15 +42,7 @@ jobs:
|
||||
run: |
|
||||
# Erstelle config.ld wenn nicht vorhanden
|
||||
if [ ! -f "config.ld" ]; then
|
||||
cat > config.ld << 'EOL'
|
||||
project = 'Basalt2'
|
||||
title = 'Basalt2 Documentation'
|
||||
description = 'A powerful UI Framework for ComputerCraft'
|
||||
dir = 'docs'
|
||||
style = '!pale'
|
||||
format = 'markdown'
|
||||
topics = {'README.md'}
|
||||
EOL
|
||||
echo 'project="Basalt2"; title="Basalt2 Documentation"; description="A powerful UI Framework for ComputerCraft"; dir="docs"; style="!pale"; format="markdown"; topics={"README.md"}' > config.ld
|
||||
fi
|
||||
|
||||
# Generiere Dokumentation
|
||||
|
||||
118
.github/workflows/minify.yml
vendored
118
.github/workflows/minify.yml
vendored
@@ -1,118 +0,0 @@
|
||||
name: Minify Lua Code
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'src/**'
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'src/**'
|
||||
|
||||
jobs:
|
||||
minify:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install Lua
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y lua5.3
|
||||
|
||||
- name: Minify Lua files
|
||||
run: |
|
||||
mkdir -p release
|
||||
|
||||
echo "Creating minification script..."
|
||||
cat > minify_script.lua << 'EOL'
|
||||
local minify = loadfile("minify.lua")()
|
||||
local lfs = require("lfs")
|
||||
|
||||
local files = {}
|
||||
|
||||
local function scanDir(dir, baseDir)
|
||||
baseDir = baseDir or ""
|
||||
for file in lfs.dir(dir) do
|
||||
if file ~= "." and file ~= ".." then
|
||||
local fullPath = dir .. "/" .. file
|
||||
local attr = lfs.attributes(fullPath)
|
||||
if attr.mode == "directory" then
|
||||
scanDir(fullPath, baseDir .. file .. "/")
|
||||
elseif file:match("%.lua$") then
|
||||
table.insert(files, {
|
||||
path = baseDir .. file,
|
||||
fullPath = fullPath
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scanDir("src")
|
||||
|
||||
local output = {
|
||||
'local minified = true\n',
|
||||
'local project = {}\n',
|
||||
'local baseRequire = require\n',
|
||||
'require = function(path) return project[path] or baseRequire(path) end\n'
|
||||
}
|
||||
|
||||
for _, file in ipairs(files) do
|
||||
local f = io.open(file.fullPath, "r")
|
||||
local content = f:read("*all")
|
||||
f:close()
|
||||
|
||||
local success, minified = minify(content)
|
||||
if not success then
|
||||
print("Failed to minify " .. file.path)
|
||||
print(minified)
|
||||
os.exit(1)
|
||||
end
|
||||
|
||||
table.insert(output, string.format(
|
||||
'project["%s"] = function(...) %s end\n',
|
||||
file.path, minified
|
||||
))
|
||||
end
|
||||
|
||||
table.insert(output, 'return project["main.lua"]')
|
||||
|
||||
local out = io.open("release/basalt.lua", "w")
|
||||
out:write(table.concat(output))
|
||||
out:close()
|
||||
EOL
|
||||
|
||||
echo "Installing LuaFileSystem..."
|
||||
sudo apt-get install -y lua-filesystem
|
||||
|
||||
echo "Running minification..."
|
||||
if lua minify_script.lua; then
|
||||
echo "Minification successful"
|
||||
echo "Files processed:"
|
||||
find src -name "*.lua" | sed 's|^src/||'
|
||||
else
|
||||
echo "Minification failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Commit minified Lua file
|
||||
if: success()
|
||||
run: |
|
||||
if [ -s release/basalt.lua ]; then
|
||||
git config --global user.name 'github-actions[bot]'
|
||||
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||
git add release/basalt.lua
|
||||
git commit -m 'Minify all Lua files into project bundle'
|
||||
git push
|
||||
else
|
||||
echo "Error: basalt.lua is empty or doesn't exist"
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
Reference in New Issue
Block a user