2018-11-30 17:39:09 -08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -eo >/dev/null
|
|
|
|
|
|
|
|
CURRENT_APPIMAGEKIT_RELEASE=9
|
|
|
|
ARCH="$(uname -m)"
|
|
|
|
|
|
|
|
if [[ $# -lt 1 ]]; then
|
2020-04-08 18:56:53 -07:00
|
|
|
echo "Usage: $0 <version>"
|
|
|
|
exit 0
|
2018-11-30 17:39:09 -08:00
|
|
|
fi
|
|
|
|
|
|
|
|
VERSION="$1"
|
|
|
|
LOVEFILE="$2"
|
2022-04-20 20:56:09 -07:00
|
|
|
USERNAME=$3
|
|
|
|
TOKEN=$4
|
2018-11-30 17:39:09 -08:00
|
|
|
|
2022-03-16 14:38:45 -07:00
|
|
|
# https://github.com/love2d/love/releases/download/11.4/love-11.4-x86_64.AppImage
|
|
|
|
# https://github.com/love2d/love/releases/download/11.3/love-11.3-x86_64.AppImage
|
|
|
|
# https://github.com/love2d/love/releases/download/11.2/love-11.2-x86_64.AppImage
|
|
|
|
# https://github.com/love2d/love/releases/download/11.1/love-11.1-linux-x86_64.AppImage
|
|
|
|
LOVE_AppImage_URL=https://github.com/love2d/love/releases/download/${VERSION}/love-${VERSION}-${ARCH}.AppImage
|
|
|
|
if [ $VERSION == "11.1" ]
|
|
|
|
then
|
|
|
|
LOVE_AppImage_URL=https://github.com/love2d/love/releases/download/${VERSION}/love-${VERSION}-linux-${ARCH}.AppImage
|
|
|
|
fi
|
2020-09-29 12:25:52 -07:00
|
|
|
CACHE_DIR=${HOME}/.cache/love-release/love
|
2022-03-16 14:38:45 -07:00
|
|
|
LOVE_AppImage=$CACHE_DIR/love-${VERSION}-${ARCH}.AppImage
|
2020-09-29 12:25:52 -07:00
|
|
|
|
|
|
|
if ! test -d ${CACHE_DIR}; then
|
2022-03-07 11:13:24 -08:00
|
|
|
mkdir -p ${CACHE_DIR}
|
2020-09-29 12:25:52 -07:00
|
|
|
fi
|
|
|
|
|
2022-04-20 20:56:09 -07:00
|
|
|
get-development-artifact(){
|
|
|
|
owner=love2d
|
|
|
|
repo=love
|
|
|
|
branch="12.0-development"
|
|
|
|
artifact="love-x86_64.AppImage" # love-windows-x64 love-macos
|
|
|
|
token=$2
|
|
|
|
username=$1
|
|
|
|
list_run_url="https://api.github.com/repos/${owner}/${repo}/actions/runs"
|
|
|
|
echo "find latest run of branch 12.0"
|
|
|
|
latest_run=$(curl -v --silent \
|
|
|
|
-H "Accept: application/vnd.github.v3+json" \
|
|
|
|
-H "Authorization token ${token}" "${list_run_url}" \
|
|
|
|
--stderr - |\
|
|
|
|
grep -B 4 "\"head_branch\": \"12.0-development\"" |\
|
|
|
|
grep "id" |\
|
|
|
|
head -1 |\
|
|
|
|
sed 's/^.* \(.*\),$/\1/g')
|
|
|
|
list_artifacts_url="https://api.github.com/repos/${owner}/${repo}/actions/runs/${latest_run}/artifacts"
|
|
|
|
echo "get artifact_url"
|
|
|
|
artifact_url=$(curl --silent \
|
|
|
|
-H "Accept: application/vnd.github.v3+json" \
|
|
|
|
-H "Authorization token ${token}" \
|
|
|
|
"${list_artifacts_url}" \
|
|
|
|
--stderr - |\
|
|
|
|
grep -A 5 "\"name\": \"${artifact}\"," |\
|
|
|
|
grep "archive_download_url" |\
|
|
|
|
head -1 |\
|
|
|
|
sed 's/^.* \"\(.*\)\",$/\1/g')
|
|
|
|
echo "download target"
|
|
|
|
echo curl -L -u ${username}:${token} ${artifact_url} -o love.zip
|
|
|
|
echo $(pwd)
|
|
|
|
rm -f love.zip love-*.AppImage && \
|
|
|
|
curl -L -u ${username}:${token} ${artifact_url} -o love.zip \
|
|
|
|
&& unzip love.zip && \
|
|
|
|
rm -f love.zip ${artifact} && \
|
|
|
|
mv love-*.AppImage ${artifact}
|
|
|
|
}
|
|
|
|
|
2022-03-16 14:38:45 -07:00
|
|
|
if ! test -f ${LOVE_AppImage}; then
|
2022-04-20 20:56:09 -07:00
|
|
|
if [ $VERSION != "12.0" ]
|
|
|
|
then
|
|
|
|
curl -L -C - -o ${LOVE_AppImage} ${LOVE_AppImage_URL}
|
|
|
|
else
|
|
|
|
get-development-artifact $USERNAME $TOKEN
|
|
|
|
mv love-x86_64.AppImage ${LOVE_AppImage}
|
|
|
|
fi
|
2022-03-16 14:38:45 -07:00
|
|
|
chmod +x ${LOVE_AppImage}
|
2020-09-29 12:25:52 -07:00
|
|
|
fi
|
|
|
|
|
2022-04-20 20:56:09 -07:00
|
|
|
echo $CACHE_DIR
|
|
|
|
|
2022-03-16 14:38:45 -07:00
|
|
|
if ! test -f ${LOVE_AppImage}; then
|
|
|
|
echo "No tarball found for $VERSION in $LOVE_AppImage"
|
2020-09-29 12:25:52 -07:00
|
|
|
exit 1
|
2018-11-30 17:39:09 -08:00
|
|
|
fi
|
|
|
|
|
|
|
|
download_if_needed() {
|
2020-04-08 18:56:53 -07:00
|
|
|
if ! test -f "$1"; then
|
|
|
|
if ! curl -L -o "$1" "https://github.com/AppImage/AppImageKit/releases/download/${CURRENT_APPIMAGEKIT_RELEASE}/$1"; then
|
|
|
|
echo "Failed to download appimagetool"
|
|
|
|
echo "Please supply it manually"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
chmod +x "$1"
|
|
|
|
fi
|
2018-11-30 17:39:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
2022-03-16 14:38:45 -07:00
|
|
|
download_if_needed appimagetool-${ARCH}.AppImage
|
2020-04-08 18:56:53 -07:00
|
|
|
# Extract the tarball build into a folder
|
|
|
|
rm -rf love-prepared
|
2022-03-07 11:13:24 -08:00
|
|
|
mkdir -p love-prepared
|
2020-04-08 18:56:53 -07:00
|
|
|
cd love-prepared
|
2022-03-16 17:22:07 -07:00
|
|
|
$LOVE_AppImage --appimage-extract 1> /dev/null 2> /dev/null
|
2022-03-16 14:38:45 -07:00
|
|
|
mv squashfs-root/* .
|
|
|
|
rm squashfs-root/.DirIcon
|
|
|
|
rmdir squashfs-root
|
2020-04-08 18:56:53 -07:00
|
|
|
# Add our small wrapper script (yay, more wrappers), and AppRun
|
|
|
|
local desktopfile="love.desktop"
|
|
|
|
local icon="love"
|
|
|
|
local target="love-${VERSION}"
|
|
|
|
|
|
|
|
if test -f ../../game.desktop.in; then
|
|
|
|
desktopfile="game.desktop"
|
|
|
|
cp ../../game.desktop.in .
|
|
|
|
fi
|
|
|
|
if test -f ../../game.svg; then
|
|
|
|
icon="game"
|
|
|
|
cp ../../game.svg .
|
|
|
|
fi
|
|
|
|
if test -f ${LOVEFILE}; then
|
2022-04-20 20:56:09 -07:00
|
|
|
if [[ $VERSION == "11.4" || $VERSION == "12.0" ]]
|
2022-03-16 14:38:45 -07:00
|
|
|
then
|
|
|
|
dir="bin"
|
|
|
|
else
|
|
|
|
dir="usr/bin"
|
|
|
|
fi
|
2020-04-08 18:56:53 -07:00
|
|
|
target="game"
|
2022-03-16 14:38:45 -07:00
|
|
|
cat $dir/love ${LOVEFILE} > $dir/love-fused
|
|
|
|
mv $dir/love-fused $dir/love
|
|
|
|
chmod +x $dir/love
|
2018-11-30 17:39:09 -08:00
|
|
|
else
|
2020-04-08 18:56:53 -07:00
|
|
|
echo "Love file ${LOVEFILE} not found"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Add our desktop file
|
2022-03-16 14:38:45 -07:00
|
|
|
mv ${desktopfile} ${desktopfile}.in
|
|
|
|
sed -e "s/%ICON%/${icon}/" "${desktopfile}.in" > "$desktopfile"
|
2020-04-08 18:56:53 -07:00
|
|
|
rm "${desktopfile}.in"
|
|
|
|
|
|
|
|
# Add a DirIcon
|
|
|
|
cp "${icon}.svg" .DirIcon
|
|
|
|
|
|
|
|
# Clean up
|
|
|
|
if test -f ../../game.desktop.in; then
|
|
|
|
rm love.desktop.in
|
|
|
|
fi
|
|
|
|
if test -f ../../game.svg; then
|
|
|
|
rm love.svg
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Now build the final AppImage
|
|
|
|
cd ..
|
|
|
|
|
2022-03-16 14:38:45 -07:00
|
|
|
# ./love-prepared/AppRun -n love-prepared "${target}-${ARCH}.AppImage"
|
2020-04-08 18:56:53 -07:00
|
|
|
# Work around missing FUSE/docker
|
2022-03-16 17:22:07 -07:00
|
|
|
./appimagetool-${ARCH}.AppImage --appimage-extract 1> /dev/null 2> /dev/null
|
|
|
|
./squashfs-root/AppRun -n love-prepared "${target}-${ARCH}.AppImage" 1> /dev/null 2> /dev/null
|
2022-04-20 20:56:09 -07:00
|
|
|
## rm -rf love-prepared/
|
2018-11-30 17:39:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|