Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@premek
Last active January 21, 2017 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save premek/867d9449df6a9825fdff5255ca175e52 to your computer and use it in GitHub Desktop.
Save premek/867d9449df6a9825fdff5255ca175e52 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -x
P="enjoy"
LV="0.10.1" # love version
LZ="https://bitbucket.org/rude/love/downloads/love-${LV}-win32.zip"
### clean
if [ "$1" == "clean" ]; then
rm -rf "target"
exit;
fi
### deploy web version to github pages
if [ "$1" == "deploy" ]; then
cd "target/${P}-web"
git init
git config user.name "autodeploy"
git config user.email "autodeploy"
touch .
git add .
git commit -m "deploy to github pages"
git push --force --quiet "https://${GH_TOKEN}@github.com/${2}.git" master:gh-pages
exit;
fi
##### build #####
find . -iname "*.lua" | xargs luac -p || { echo 'luac parse test failed' ; exit 1; }
mkdir "target"
### .love
cp -r src target
cd target/src
# compile .ink story into lua table so the runtime will not need lpeg dep.
lua lib/pink/pink/pink.lua parse game.ink > game.lua
# .love file
zip -9 -r - . > "../${P}.love"
cd -
### .exe
if [ ! -f "target/love-win.zip" ]; then wget "$LZ" -O "target/love-win.zip"; fi
unzip -o "target/love-win.zip" -d "target"
tmp="target/tmp/"
mkdir -p "$tmp/$P"
cat "target/love-${LV}-win32/love.exe" "target/${P}.love" > "$tmp/${P}/${P}.exe"
cp target/love-"${LV}"-win32/*dll target/love-"${LV}"-win32/license* "$tmp/$P"
cd "$tmp"
zip -9 -r - "$P" > "${P}-win.zip"
cd -
cp "$tmp/${P}-win.zip" "target/"
rm -r "$tmp"
### web
if [ "$1" == "web" ]; then
cd target
rm -rf love.js *-web*
git clone https://github.com/TannerRogalsky/love.js.git
cd love.js
git checkout 6fa910c2a28936c3ec4eaafb014405a765382e08
git submodule update --init --recursive
cd release-compatibility
python ../emscripten/tools/file_packager.py game.data --preload ../../../target/src/@/ --js-output=game.js
python ../emscripten/tools/file_packager.py game.data --preload ../../../target/src/@/ --js-output=game.js
#yes, two times!
# python -m SimpleHTTPServer 8000
cd ../..
cp -r love.js/release-compatibility "$P-web"
zip -9 -r - "$P-web" > "${P}-web.zip"
# target/$P-web/ goes to webserver
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment