Skip to content

Commit

Permalink
chore(github-workflow): Run tweego directly
Browse files Browse the repository at this point in the history
  • Loading branch information
kulla committed Jan 22, 2024
1 parent 0f98019 commit d6a98f9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Flatpak
- name: Download and install tweego
run: |
sudo apt update
sudo apt install flatpak flatpak-builder -y
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak --version
flatpak-builder --version
- name: Install platform and SDK for flatpak
run: sudo flatpak install --assumeyes flathub org.freedesktop.Platform//23.08 org.freedesktop.Sdk//23.08

- name: Install tweego
run: make install
wget -O tweego.zip https://github.com/tmedwards/tweego/releases/download/v2.1.1/tweego-2.1.1-linux-x64.zip
scripts/setup.sh tweego.zip /usr/local/bin
- name: Build the story `story.twee`
run: make run
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ default: help
build:
flatpak-builder --force-clean $(BUILD_DIR) $(MANIFEST)

clean:
rm -rfv .flatpak-builder

help:
@echo "Usage: make [command]"
@echo ""
@echo "Commands:"
@echo ""
@echo "build – Build tweego"
@echo "clean – Clean build cache"
@echo "install – Install tweego"
@echo "run – Run tweego with story.twee"

Expand All @@ -26,6 +30,4 @@ public:
mkdir -p public

run: story.twee public
flatpak run --filesystem=$(PWD)/story.twee:ro \
--filesystem=$(PWD)/public:rw $(NAME) \
-o public/index.html $<
scripts/run.sh $(NAME) $< public/index.html
15 changes: 15 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/sh
#
# Run tweego directly or with flatpak

NAME="$1"
STORY="$2"
TARGET="$3"

if command -v tweego; then
COMMAND="tweego"
else
COMMAND="flatpak run --filesystem=$PWD/$STORY:ro --filesystem=$PWD/$TARGET:rw $NAME"
fi

$COMMAND -o "$TARGET" "$STORY"
16 changes: 16 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/sh
#
# Script to install tweego

set -e

ZIP_FILE="$1"
TARGET_PATH="$2"

if [ -z "$ZIP_FILE" ] || [ -z "$TARGET_PATH" ]; then
>&2 echo "Error: Arguments ZIP_FILE and TARGET_PATH cannot be empty"
exit 1
fi

unzip "$ZIP_FILE" -d "$TARGET_PATH"
chmod +x "$TARGET_PATH/tweego"

0 comments on commit d6a98f9

Please sign in to comment.