From ba7d604dfa0eb1b56d468a83d8154de2c2e1982a Mon Sep 17 00:00:00 2001
From: Christopher Peredy <16451370+mastercaution@users.noreply.github.com>
Date: Mon, 8 Nov 2021 17:54:17 +0100
Subject: [PATCH] Automate release with release script
---
.gitignore | 1 +
FlatLogicWorld/manifest.succ | 2 +-
README.md | 9 ++++++++-
utils/release.sh | 31 +++++++++++++++++++++++++++++++
4 files changed, 41 insertions(+), 2 deletions(-)
create mode 100644 .gitignore
create mode 100755 utils/release.sh
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..00c0a68
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+FlatLogicWorld_v*.zip
\ No newline at end of file
diff --git a/FlatLogicWorld/manifest.succ b/FlatLogicWorld/manifest.succ
index aea6514..c6aa9ca 100644
--- a/FlatLogicWorld/manifest.succ
+++ b/FlatLogicWorld/manifest.succ
@@ -1,5 +1,5 @@
ID: FlatLogicWorld
Name: Flat Logic World
Author: ChrisP
-Version: 0.1.0
+Version: !VERSION!
Priority: 0
diff --git a/README.md b/README.md
index d76149e..fae5088 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
-
+
+## "Build" it Yourself
+You can create the release ZIP file yourself by simply executing the `release.sh` script (Linux only, needs `sed` and `zip` (default on most distros)):
+```
+utils/release.sh
+```
+This script will automatically cut out all unnecessary comments and create a ZIP file. The content can be placed directly into the mod folder of Logic World.
+> :warning: The version number is taken from the latest git tag.
## Acknowledgements
Huge thanks to Mouse Hat Games (especially Jimmy) for the great game and the modularity making it super easy to create custom themes and other mods!
diff --git a/utils/release.sh b/utils/release.sh
new file mode 100755
index 0000000..38a2e4b
--- /dev/null
+++ b/utils/release.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+dirname $(readlink -f "$0")
+
+if git rev-parse --git-dir > /dev/null 2>&1; then
+ VERSION=$(git describe --tag)
+else
+ VERSION="vUNKNOWN"
+fi
+
+PREFIX="v"
+VERSION_NR=${VERSION#$PREFIX}
+
+mkdir -p build
+cp -ru FlatLogicWorld build
+
+IFS_BACKUP=$IFS
+IFS=$'\n'
+FILES=build/FlatLogicWorld/palettes/*.succ
+for palette in $FILES ; do
+ sed -i '1,2p; /^[[:blank:]]*#/d;s/#.*//' $palette
+ sed -i 's/[ \t]*$//' $palette
+done
+IFS=$IFS_BACKUP
+
+sed -i "s/!VERSION!/$VERSION_NR/" build/FlatLogicWorld/manifest.succ
+
+cd build
+zip -FSr ../FlatLogicWorld_$VERSION.zip FlatLogicWorld
+cd ..
+
+rm -rf build
\ No newline at end of file