90 lines
2.4 KiB
YAML
90 lines
2.4 KiB
YAML
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: Set up Node.js
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '14'
|
|
|
|
- name: Install Lua minifier
|
|
run: npm install -g luamin
|
|
|
|
- name: Combine Lua files
|
|
run: |
|
|
echo "Creating release directory"
|
|
mkdir -p release
|
|
echo "Creating project.lua file"
|
|
echo "local project = {}" > release/project.lua
|
|
for file in $(find src -name '*.lua'); do
|
|
echo "Adding $file to project.lua"
|
|
cat $file >> release/project.lua
|
|
done
|
|
echo "Combined Lua files:"
|
|
cat release/project.lua
|
|
|
|
- name: Verify combined Lua file
|
|
run: |
|
|
echo "Verifying project.lua"
|
|
if [ -f release/project.lua ]; then
|
|
echo "project.lua exists"
|
|
cat release/project.lua
|
|
else
|
|
echo "Error: release/project.lua not found"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Commit combined Lua file
|
|
run: |
|
|
git config --global user.name 'github-actions[bot]'
|
|
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
|
git add release/project.lua
|
|
git commit -m 'Combine Lua files into a single project.lua'
|
|
git push
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Minify combined Lua file
|
|
run: |
|
|
echo "Minifying project.lua"
|
|
luamin -f release/project.lua -o release/project.min.lua
|
|
|
|
- name: Verify minified Lua file
|
|
run: |
|
|
echo "Verifying project.min.lua"
|
|
if [ -f release/project.min.lua ]; then
|
|
echo "project.min.lua exists"
|
|
cat release/project.min.lua
|
|
else
|
|
echo "Error: release/project.min.lua not found"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Commit minified Lua file
|
|
run: |
|
|
git config --global user.name 'github-actions[bot]'
|
|
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
|
git add release/project.min.lua
|
|
git commit -m 'Minify Lua files into a single project.min.lua'
|
|
git push
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|