74 lines
1.9 KiB
YAML
74 lines
1.9 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: '16'
|
|
|
|
- name: Install Lua minifier
|
|
run: |
|
|
npm install luamin
|
|
echo "Testing luamin installation:"
|
|
npx luamin --version || echo "luamin version check failed"
|
|
|
|
- name: Combine and Minify Lua files
|
|
run: |
|
|
set -x # Enable debug output
|
|
|
|
echo "Creating release directory"
|
|
mkdir -p release
|
|
|
|
echo "Creating and populating project.lua"
|
|
{
|
|
echo "local project = {}"
|
|
find src -name '*.lua' -exec cat {} \;
|
|
} > release/project.lua
|
|
|
|
echo "Content of project.lua:"
|
|
cat release/project.lua
|
|
|
|
echo "Attempting minification..."
|
|
if npx luamin -f release/project.lua > release/project.min.lua; then
|
|
echo "Minification successful"
|
|
echo "Minified content size: $(wc -c < release/project.min.lua) bytes"
|
|
else
|
|
echo "Minification failed"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Commit minified Lua file
|
|
if: success()
|
|
run: |
|
|
if [ -s release/project.min.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/project.min.lua
|
|
git commit -m 'Minify Lua files into a single project.min.lua'
|
|
git push
|
|
else
|
|
echo "Error: project.min.lua is empty or doesn't exist"
|
|
exit 1
|
|
fi
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|