Automatically squish Lua scripts for floppy disk versions (keep Zip v… #229
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lua for Watcom | |
| on: push | |
| jobs: | |
| Watcom: | |
| name: Build Lua with Open Watcom | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Install Open Watcom 1.9 | |
| uses: open-watcom/setup-watcom@v0 | |
| with: | |
| version: "1.9" | |
| - name: Install Other Tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc libfaketime libreadline-dev lua5.4 make mtools zip | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Check S256SUM.LUA Integrity | |
| run: | | |
| LUA=$(lua demo/core/S256SUM.LUA demo/core/S256SUM.LUA) | |
| GNU=$(sha256sum demo/core/S256SUM.LUA) | |
| echo "LUA=$LUA" | |
| echo "GNU=$GNU" | |
| if [ "$LUA" != "$GNU" ]; then exit 1; fi | |
| - name: Check MD5SUM.LUA Integrity | |
| run: | | |
| LUA=$(lua demo/xtra/MD5SUM.LUA demo/xtra/MD5SUM.LUA) | |
| GNU=$(md5sum demo/xtra/MD5SUM.LUA) | |
| echo "LUA=$LUA" | |
| echo "GNU=$GNU" | |
| if [ "$LUA" != "$GNU" ]; then exit 1; fi | |
| - name: Test libfaketime works | |
| run: | | |
| export FAKETIME=$(TZ=UTC0 git show --quiet --date='format-local:%Y-%m-%d %H:%M:%S' --format="%cd") | |
| export LD_PRELOAD=$(dpkg -L libfaketime | grep libfaketime.so.1) | |
| DATE=$(date +"%Y-%m-%d %H:%M:%S") | |
| echo "Date: $DATE" | |
| echo "Faketime: $FAKETIME" | |
| echo "ld-preload: $LD_PRELOAD" | |
| if [ "$FAKETIME" != "$DATE" ]; then | |
| exit 1 | |
| fi | |
| - name: Patch Lua Source Code for Open Watcom | |
| run: | | |
| lua demo/xtra/PATCH.LUA lua.pat | |
| - name: Check GCC can build Lua after patches | |
| run: | | |
| cd lua | |
| make -j`nproc` | |
| cd .. | |
| - name: Build Lua for DOS 16-bit | |
| env: | |
| INCLUDE: "${{ env.WATCOM }}/h" | |
| run: | | |
| wmake -f wm_dos16.mak | |
| - name: Build Lua for DOS4GW 32-bit Extender | |
| env: | |
| INCLUDE: "${{ env.WATCOM }}/h" | |
| run: | | |
| wmake -f wm_dos4g.mak | |
| - name: Build Lua for Linux | |
| env: | |
| INCLUDE: "${{ env.WATCOM }}/lh" | |
| run: | | |
| wmake -f wm_linux.mak | |
| - name: Build Lua for OS/2 16-bit | |
| env: | |
| INCLUDE: "${{ env.WATCOM }}/h/os2:${{ env.WATCOM }}/h" | |
| run: | | |
| wmake -f wm_os216.mak | |
| - name: Build Lua for OS/2 32-bit | |
| env: | |
| INCLUDE: "${{ env.WATCOM }}/h/os2:${{ env.WATCOM }}/h" | |
| run: | | |
| wmake -f wm_os232.mak | |
| - name: Build Lua for Windows 95 | |
| env: | |
| INCLUDE: "${{ env.WATCOM }}/h/nt:${{ env.WATCOM }}/h" | |
| run: | | |
| wmake -f wm_winnt.mak | |
| - name: Copy DOS4GW Binary | |
| run: | | |
| cp $WATCOM/binw/dos4gw.exe dist/bin/DOS4GW.EXE | |
| - name: Ensure Lua Scripts Have CR/LF Line Endings | |
| run: | | |
| lua demo/xtra/DOSFREN.LUA demo/core/*.LUA demo/xtra/*.LUA | |
| - name: Set constant time information on PE header | |
| run: | | |
| lua demo/util/PE95TIME.LUA dist/bin/LUANT.EXE | |
| - name: Set modification time on scripts to their respective commit | |
| run: | | |
| cd demo | |
| git ls-files -z | xargs -0 -I{} bash -c 'touch --date="$(git log -1 --pretty=format:%cI -- "$0")" "$0"' {} | |
| cd .. | |
| - name: Remove UNIX executable permission from non-UNIX executable files | |
| run: | | |
| chmod -x dist/bin/*.EXE | |
| - name: Set modification time on built binaries to the latest commit | |
| run: | | |
| touch --date="$(git log -1 --pretty=format:%cI)" dist/bin/*.ELF dist/bin/*.EXE | |
| - name: Create Binaries Zip | |
| run: | | |
| files=$(find dist/bin/*.EXE demo/core/*.LUA demo/xtra/*.LUA ! -executable | sort | xargs) | |
| zip -j9 --DOS-names dist/LuaExe.zip $files | |
| exe=$(find dist/bin/*.ELF demo/core/*.LUA demo/xtra/*.LUA -executable | sort | xargs) | |
| zip -j9 -X dist/LuaExe.zip $exe | |
| name="dist/WLE$(sha256sum dist/LuaExe.zip | awk '{print $1}' | cut -c1-5).zip" | |
| mv dist/LuaExe.zip $name | |
| touch --date="$(git log -1 --pretty=format:%cI)" $name | |
| - name: UPX Binary Compression | |
| uses: crazy-max/ghaction-upx@v3 | |
| with: | |
| version: latest | |
| args: -9 --8086 | |
| files: | | |
| dist/bin/LUA16.EXE | |
| dist/bin/LUA4G.EXE | |
| dist/bin/LUANT.EXE | |
| - name: Squish Lua Scripts for Floppy Disk Images | |
| run: | | |
| find demo -name "*.LUA" -type f -exec demo/util/SQUISH.LUA {} + | |
| find demo -name "*.LUA" -type f -exec demo/xtra/DOSFREN.LUA {} + | |
| - name: Set modification time on UPX compressed binaries to the latest commit | |
| run: | | |
| touch --date="$(git log -1 --pretty=format:%cI)" dist/bin/*.ELF dist/bin/*.EXE | |
| - name: Set modification time on squished scripts to their respective commit | |
| run: | | |
| cd demo | |
| git ls-files -z | xargs -0 -I{} bash -c 'touch --date="$(git log -1 --pretty=format:%cI -- "$0")" "$0"' {} | |
| cd .. | |
| - name: Create 160k 16-bit DOS Floppy Diskette Image | |
| run: | | |
| export FAKETIME=$(TZ=UTC0 git show --quiet --date='format-local:%Y-%m-%d %H:%M:%S' --format="%cd") | |
| export LD_PRELOAD=$(dpkg -L libfaketime | grep libfaketime.so.1) | |
| label="LUA DOS" | |
| serial="0x$(echo "$label$FAKETIME" | sha256sum | cut -c1-8)" | |
| files=$(find dist/bin/LUA16.EXE demo/core/*.LUA | sort | xargs) | |
| echo "Faketime: $FAKETIME" | |
| echo "Files: $files" | |
| echo "Label: $label" | |
| echo "Serial: $serial" | |
| mformat -C -i dist/Lua160k.ima -v "$label" -f 160 -N $serial | |
| mcopy -mi dist/Lua160k.ima $files :: | |
| - name: Create 1.4M Multi-Platform Floppy Diskette Image | |
| run: | | |
| export FAKETIME=$(TZ=UTC0 git show --quiet --date='format-local:%Y-%m-%d %H:%M:%S' --format="%cd") | |
| export LD_PRELOAD=$(dpkg -L libfaketime | grep libfaketime.so.1) | |
| label="LUA MULTIOS" | |
| serial="0x$(echo "$label$FAKETIME" | sha256sum | cut -c1-8)" | |
| files=$(find dist/bin/*.ELF dist/bin/*.EXE demo/core/*.LUA demo/xtra/*.LUA | sort | xargs) | |
| echo "Faketime: $FAKETIME" | |
| echo "Files: $files" | |
| echo "Label: $label" | |
| echo "Serial: $serial" | |
| mformat -C -i dist/LuaMulti.ima -v "$label" -f 1440 -N $serial | |
| mcopy -mi dist/LuaMulti.ima $files :: | |
| - name: Zero-out Unallocated Clusters | |
| run: | | |
| lua demo/util/FATSTAT.LUA -z dist/*ima | |
| - name: Create Floppy Disk Images Zip | |
| run: | | |
| files=$(find dist/*ima | sort | xargs) | |
| touch --date="$(git log -1 --pretty=format:%cI)" $files | |
| zip -j9 --DOS-names dist/LuaIma.zip $files | |
| name="dist/WLI$(sha256sum dist/LuaIma.zip | awk '{print $1}' | cut -c1-5).zip" | |
| mv dist/LuaIma.zip $name | |
| touch --date="$(git log -1 --pretty=format:%cI)" $name | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: 'LuaDist' | |
| path: | | |
| dist/WLE*.zip | |
| dist/WLI*.zip | |
| compression-level: 0 | |
| Draft: | |
| name: Draft Release | |
| needs: Watcom | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/202') | |
| permissions: | |
| contents: write | |
| actions: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Generate Release Notes | |
| run: | | |
| input_date="$TAG_NAME" | |
| day=$(date -d "$input_date" '+%-d') | |
| month=$(date -d "$input_date" '+%B') | |
| year=$(date -d "$input_date" '+%Y') | |
| if [[ $day -eq 11 || $day -eq 12 || $day -eq 13 ]]; then | |
| suffix="th" | |
| else | |
| case $((day % 10)) in | |
| 1) suffix="st" ;; | |
| 2) suffix="nd" ;; | |
| 3) suffix="rd" ;; | |
| *) suffix="th" ;; | |
| esac | |
| fi | |
| formatted_date="${day}${suffix} of ${month} ${year}" | |
| sed -i "s/{{DATE}}/${formatted_date}/g" .github/workflows/notes.md | |
| name="$(ls LuaDist/WLE*.zip | xargs -n 1 basename)" | |
| sed -i "s/{{WLE}}/${name}/g" .github/workflows/notes.md | |
| name="$(ls LuaDist/WLI*.zip | xargs -n 1 basename)" | |
| sed -i "s/{{WLI}}/${name}/g" .github/workflows/notes.md | |
| - name: Create Draft Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG_NAME="${GITHUB_REF#refs/tags/}" # Extract the tag name | |
| gh release create "$TAG_NAME" \ | |
| --draft \ | |
| --title "$TAG_NAME" \ | |
| --notes-file .github/workflows/notes.md \ | |
| "LuaDist/*.zip" |