Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Create AppImage package #248

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
matrix:
include:
- name: Linux
os: ubuntu-latest
os: ubuntu-20.04
- name: Mac
os: macos-latest
steps:
Expand All @@ -35,3 +35,15 @@ jobs:
brew install sdl2 coreutils
- name: Build
run: make -j$(nproc) zelda3

- name: Package AppImage
if: ${{ matrix.name == 'Linux' }}
run: |
platform/appimage/appimage.sh

- name: Upload AppImage
if: ${{ matrix.name == 'Linux' }}
uses: actions/upload-artifact@v3
with:
name: Zelda3
path: uploads/
86 changes: 86 additions & 0 deletions platform/appimage/AppRun
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/bash

SCRIPT_PATH=`dirname $(realpath $0)`/usr
export LD_LIBRARY_PATH=${SCRIPT_PATH}/lib
export LC_NUMERIC=en_US.UTF-8
export ZELDA_ROM=$(shasum *.s[mf]c | grep -i 6D4F10A8B10E10DBE624CB23CF03B88BB8252973 | awk '{ print $2 }')
export LANG_ROM=$(shasum *.s[mf]c | awk ' { print $2 }' | sed '/zelda3.sfc/ d')
export LANG_ROM_HASH=$(shasum *.s[mf]c | awk '{ print toupper($1) }' | sed '/6D4F10A8B10E10DBE624CB23CF03B88BB8252973/I d')

extract_language () {
sed -i 's/# Language/Language/g' "$ASSETDIR"/zelda3.ini
sed -i "s/Language = .*/Language = $1/g" "$ASSETDIR"/zelda3.ini
"${SCRIPT_PATH}"/bin/notify-send -i "${SCRIPT_PATH}"/../zelda3.png "Translating..."
"${SCRIPT_PATH}"/bin/python3 restool.py --extract-dialogue -r translate.sfc
"${SCRIPT_PATH}"/bin/python3 restool.py --languages="$1"
}

if [ ! -e zelda3_assets.dat ]; then
if [ ! -e "$ZELDA_ROM" ]; then
"${SCRIPT_PATH}"/bin/notify-send -i "${SCRIPT_PATH}"/../zelda3.png "Missing ROM file"
exit
else
export ASSETDIR="$(mktemp -d /tmp/assets-XXXXX)"
cp -r "${SCRIPT_PATH}"/assets/* "$ASSETDIR"
ln -s "$PWD"/"$ZELDA_ROM" "$ASSETDIR"/tables/zelda3.sfc
if [ -e "$LANG_ROM" ]; then
ln -s "$PWD"/"$LANG_ROM" "$ASSETDIR"/tables/translate.sfc
fi
cd "$ASSETDIR"/tables
"${SCRIPT_PATH}"/bin/notify-send -i "${SCRIPT_PATH}"/../zelda3.png "Extracting Assets"
"${SCRIPT_PATH}"/bin/python3 restool.py --extract-from-rom -r zelda3.sfc
if [ -e "translate.sfc" ]; then
case "$LANG_ROM_HASH" in
2E62494967FB0AFDF5DA1635607F9641DF7C6559)
extract_language "de"
;;
229364A1B92A05167CD38609B1AA98F7041987CC)
extract_language "fr"
;;
C1C6C7F76FFF936C534FF11F87A54162FC0AA100)
extract_language "fr-c"
;;
7C073A222569B9B8E8CA5FCB5DFEC3B5E31DA895)
extract_language "en"
;;
461FCBD700D1332009C0E85A7A136E2A8E4B111E)
extract_language "es"
;;
3C4D605EEFDA1D76F101965138F238476655B11D)
extract_language "pl"
;;
D0D09ED41F9C373FE6AFDCCAFBF0DA8C88D3D90D)
extract_language "pt"
;;
B2A07A59E64C498BC1B2F28728F9BF4014C8D582)
extract_language "redux"
;;
9325C22EB0A2A1F0017157C8B620BC3A605CEDE1)
extract_language "redux"
;;
FA8ADFDBA2697C9A54D583A1284A22AC764C7637)
extract_language "nl"
;;
43CD3438469B2C3FE879EA2F410B3EF3CB3F1CA4)
extract_language "sv"
;;
*)
"${SCRIPT_PATH}"/bin/notify-send -i "${SCRIPT_PATH}"/../zelda3.png "Unknown ROM file"
exit
;;
esac
fi
cd -
cp "$ASSETDIR"/tables/zelda3_assets.dat .
cp "$ASSETDIR"/zelda3.ini .
rm -r "$ASSETDIR"
fi
fi

if [ ! -e zelda3.ini ]; then
cp "${SCRIPT_PATH}"/assets/zelda3.ini .
fi

"${SCRIPT_PATH}"/bin/zelda3 $@

exit
20 changes: 20 additions & 0 deletions platform/appimage/appimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

export LINUXDEPLOY="./linuxdeploy-x86_64.AppImage --appimage-extract-and-run"
export CONDA_PACKAGES="pyyaml;pillow"
curl -sSfLO https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
curl -sSfLO https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-conda/master/linuxdeploy-plugin-conda.sh
chmod +x linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-plugin-conda.sh
$LINUXDEPLOY --appdir=AppDir
cp zelda3 AppDir/usr/bin/
cp platform/appimage/{AppRun,zelda3.desktop,zelda3.png} AppDir
chmod +x AppDir/AppRun
chmod +x AppDir/usr/bin/zelda3
mkdir -p AppDir/usr/assets
cp -r {tables,other} AppDir/usr/assets/
cp zelda3.ini AppDir/usr/assets/
cp /usr/bin/notify-send AppDir/usr/bin/
$LINUXDEPLOY --appdir=AppDir --plugin conda --output appimage
mkdir uploads
mv Zelda*.AppImage uploads
9 changes: 9 additions & 0 deletions platform/appimage/zelda3.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Name=Zelda3
Exec=zelda3
Terminal=false
Type=Application
Icon=zelda3
Comment=Zelda3 port
Categories=Game;
StartupWMClass=zelda3;
Binary file added platform/appimage/zelda3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.