Test workflow
This commit is contained in:
43
.github/workflows/main.yml
vendored
43
.github/workflows/main.yml
vendored
@@ -19,25 +19,56 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Install Lua
|
- name: Setup Lua
|
||||||
run: |
|
uses: leafo/gh-actions-lua@v8
|
||||||
sudo apt-get update
|
with:
|
||||||
sudo apt-get install -y lua5.3
|
luaVersion: "5.4"
|
||||||
|
|
||||||
|
# Step 1: Config Generation
|
||||||
- name: Generate Config
|
- name: Generate Config
|
||||||
run: |
|
run: |
|
||||||
lua tools/generate-config.lua
|
lua tools/generate-config.lua
|
||||||
|
|
||||||
|
# Step 2: Generate LuaLS Definitions
|
||||||
|
- name: Generate LuaLS
|
||||||
|
run: |
|
||||||
|
lua tools/annotationParser.lua src/elements src/LuaLS.lua
|
||||||
|
|
||||||
|
# Step 3: Bundle and Minify
|
||||||
|
- name: Bundle and Minify
|
||||||
|
run: |
|
||||||
|
mkdir -p release
|
||||||
|
lua tools/bundler.lua
|
||||||
|
|
||||||
|
# Step 4: Prepare and Generate Documentation
|
||||||
|
- name: Prepare docs directory
|
||||||
|
run: |
|
||||||
|
mkdir -p build_docs/docs/references
|
||||||
|
|
||||||
|
- name: Generate Documentation
|
||||||
|
run: |
|
||||||
|
lua tools/generate-docs.lua
|
||||||
|
|
||||||
|
# Step 5: Deploy Documentation
|
||||||
|
- name: Deploy Documentation
|
||||||
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
publish_dir: ./build_docs
|
||||||
|
|
||||||
|
# Step 6: Generate Changelog
|
||||||
- name: Generate Changelog
|
- name: Generate Changelog
|
||||||
id: changelog
|
id: changelog
|
||||||
uses: heinrichreimer/github-changelog-generator-action@v2.3
|
uses: heinrichreimer/github-changelog-generator-action@v2.3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# Step 7: Commit all changes
|
||||||
- name: Commit Changes
|
- name: Commit Changes
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name 'github-actions[bot]'
|
git config --global user.name 'github-actions[bot]'
|
||||||
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
||||||
git add config.lua CHANGELOG.md
|
git add config.lua src/LuaLS.lua release/basalt.lua CHANGELOG.md
|
||||||
git commit -m "Update config and changelog" || exit 0
|
git commit -m "Update config, LuaLS definitions, bundle and changelog" || exit 0
|
||||||
git push
|
git push
|
||||||
@@ -201,5 +201,4 @@ function basalt.getAPI(name)
|
|||||||
return elementManager.getAPI(name)
|
return elementManager.getAPI(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return basalt
|
return basalt
|
||||||
56
tools/bundler.lua
Normal file
56
tools/bundler.lua
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
local minify = loadfile("tools/minify.lua")()
|
||||||
|
|
||||||
|
local function scanDir(dir)
|
||||||
|
local files = {}
|
||||||
|
for file in io.popen('find "'..dir..'" -type f -name "*.lua"'):lines() do
|
||||||
|
if not file:match("LuaLS.lua$") then
|
||||||
|
table.insert(files, {
|
||||||
|
path = file:gsub("^src/", ""),
|
||||||
|
fullPath = file
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return files
|
||||||
|
end
|
||||||
|
|
||||||
|
local function bundle()
|
||||||
|
local files = 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()
|
||||||
|
|
||||||
|
print("Successfully bundled files:")
|
||||||
|
for _, file in ipairs(files) do
|
||||||
|
print("- " .. file.path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
bundle()
|
||||||
19
tools/generate-docs.lua
Normal file
19
tools/generate-docs.lua
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
local function processFile(inputFile, outputFile)
|
||||||
|
local f = io.open(inputFile, "r")
|
||||||
|
local content = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
|
||||||
|
local out = io.open(outputFile, "w")
|
||||||
|
out:write(content)
|
||||||
|
out:close()
|
||||||
|
|
||||||
|
print("Generated docs for: " .. inputFile)
|
||||||
|
end
|
||||||
|
|
||||||
|
for file in io.popen('find "src" -type f -name "*.lua"'):lines() do
|
||||||
|
if not file:match("LuaLS.lua$") then
|
||||||
|
local outputFile = "build_docs/docs/references/" .. file:gsub("^src/", ""):gsub("%.lua$", ".md")
|
||||||
|
processFile(file, outputFile)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user