From 25cf106fe3e2964fd957c0e3165ad67d65078e74 Mon Sep 17 00:00:00 2001 From: Alexander Griffith Date: Wed, 20 Apr 2022 23:56:09 -0400 Subject: [PATCH] Can now target latest 12.0 branch build --- .gitignore | 5 ++-- buildtools/appimage/build.sh | 54 ++++++++++++++++++++++++++++++++++-- makefile | 5 +++- readme.org | 17 ++++++++++++ 4 files changed, 74 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 393d4e2..9d5b3d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ *~ /releases /buildtools/appimage/love-prepared/ -/buildtools/appimage/game-x86_64.AppImage -/buildtools/appimage/love-11.4-x86_64.AppImage -/buildtools/appimage/appimagetool-x86_64.AppImage +/buildtools/appimage/*.AppImage /buildtools/appimage/squashfs-root +*.private \ No newline at end of file diff --git a/buildtools/appimage/build.sh b/buildtools/appimage/build.sh index f88992b..29174e5 100755 --- a/buildtools/appimage/build.sh +++ b/buildtools/appimage/build.sh @@ -12,6 +12,8 @@ fi VERSION="$1" LOVEFILE="$2" +USERNAME=$3 +TOKEN=$4 # 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 @@ -29,11 +31,57 @@ if ! test -d ${CACHE_DIR}; then mkdir -p ${CACHE_DIR} fi +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} +} + if ! test -f ${LOVE_AppImage}; then - curl -L -C - -o ${LOVE_AppImage} ${LOVE_AppImage_URL} + 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 chmod +x ${LOVE_AppImage} fi +echo $CACHE_DIR + if ! test -f ${LOVE_AppImage}; then echo "No tarball found for $VERSION in $LOVE_AppImage" exit 1 @@ -74,7 +122,7 @@ main() { cp ../../game.svg . fi if test -f ${LOVEFILE}; then - if [ $VERSION == "11.4" ] + if [[ $VERSION == "11.4" || $VERSION == "12.0" ]] then dir="bin" else @@ -111,7 +159,7 @@ main() { # Work around missing FUSE/docker ./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 - rm -rf love-prepared/ + ## rm -rf love-prepared/ } main "$@" diff --git a/makefile b/makefile index 9a6550b..b688c27 100644 --- a/makefile +++ b/makefile @@ -5,6 +5,8 @@ ITCH_ACCOUNT=change-me-too URL=https://gitlab.com/alexjgriffith/min-love2d-fennel AUTHOR="Your Name" DESCRIPTION="Minimal setup for trying out Phil Hagelberg's fennel/love game design process." +GITHUB_USERNAME=`grep -f GITHUB_USERNAME credentials.private | cut -d= -f2` +GITHUB_PAT=`grep -f GITHUB_PAT credentials.private | cut -d= -f2` LIBS := $(wildcard lib/*) LUA := $(wildcard *.lua) SRC := $(wildcard *.fnl) @@ -30,7 +32,8 @@ FLAGS=-a "$(AUTHOR)" --description $(DESCRIPTION) \ --love $(LOVE_VERSION) --url $(URL) --version $(VERSION) --lovefile $(LOVEFILE) releases/$(NAME)-$(VERSION)-x86_64.AppImage: $(LOVEFILE) - cd buildtools/appimage && ./build.sh $(LOVE_VERSION) $(PWD)/$(LOVEFILE) + cd buildtools/appimage && \ + ./build.sh $(LOVE_VERSION) $(PWD)/$(LOVEFILE) $(GITHUB_USERNAME) $(GITHUB_PAT) mv buildtools/appimage/game-x86_64.AppImage $@ releases/$(NAME)-$(VERSION)-macos.zip: $(LOVEFILE) diff --git a/readme.org b/readme.org index 16a6039..57243ce 100644 --- a/readme.org +++ b/readme.org @@ -72,6 +72,23 @@ Presently the only layouts are =clone= and =seperate-source=. If you want to mak Use =make linux=, =make windows=, =make mac=, or =make web= to create targets for each platform, or =make release= to make all four. Check out the makefile for more commands, and remember to edit your game data in it! +* Targeting the development branch of love (12.0) - LINUX ONLY +You can target the development branch of love (version 12.0) by setting the `LOVE_VERSION` parameter in the makefile to 12.0. Note that because we are working from a github artifact, rather than a release, you will also have to pass in your github username and a github PAT. + +** Getting a PAT +To download artifacts created by the Github actions CI you will need to get an access token from "settings -> developer settings -> personal access tokens". The token needs `workflow` and `actions:read` permissions. + +** Creating a credentials.private file +By default the makefile looks for `credentials.private` in the root directory of the project. `*.private` is part of `.gitignore` so personal information stored here will not be part of the git history or get pushed to a remote server. + +The contents should look something like this: +#+BEGIN_SRC bash +GITHUB_USERNAME=username +GITHUB_PAT=PAT +#+END_SRC + +Note: this is presently linux only, however it may be expanded in the future to cover macos and windows. + * Phil's Modal Callbacks (PMC) Phil Hegelberg's [[https://gitlab.com/technomancy/exo-encounter-667/][exo-encounter-667]] is structured using a modal callback system. Each game state has a mode and each mode has a series of specific callbacks.