Skip to content

Instantly share code, notes, and snippets.

@rhys-vdw
Last active December 16, 2018 23:45
Show Gist options
  • Save rhys-vdw/6aabc0c17488e9e93de18c531087b5ee to your computer and use it in GitHub Desktop.
Save rhys-vdw/6aabc0c17488e9e93de18c531087b5ee to your computer and use it in GitHub Desktop.
Copy itch binaries to a different project
#!/usr/bin/env bash
# -- Set debug flags --
set -e
# -- Utility --
# see: https://stackoverflow.com/questions/2990414/echo-that-outputs-to-stderr#comment50764513_23550347
errcho(){ >&2 echo $@; }
# -- Handle environment vars --
if [[ -z "${SRC_ITCH_PROJECT}" ]]; then
errcho "ERROR: SRC_ITCH_PROJECT not set.";
exit 1;
fi
if [[ -z "${DEST_ITCH_PROJECT}" ]]; then
errcho "ERROR: DEST_ITCH_PROJECT not set.";
exit 1;
fi
# -- Reset build folder --
SCRIPTS_PATH=`dirname "$(realpath $0)"`
PROJECT_PATH=$(cd "$SCRIPTS_PATH/.." && pwd)
BUILD_PATH=$PROJECT_PATH/Builds
rm -rf $BUILD_PATH
mkdir -p $BUILD_PATH
# -- Get list of channels --
STATUS=`butler status $SRC_ITCH_PROJECT | tail -n +4 | ghead -n -1`
CHANNELS=`echo "$STATUS" | cut -d "|" -f2 | grep -oE '([^ ]+)'`
VERSION=`echo "$STATUS" | cut -d "|" -f5 | grep -oE "([^ ]+)" | uniq`
# -- Ensure that we only have one version --
VERSION_COUNT=`echo $VERSION | wc -l | xargs`
if [ "$VERSION_COUNT" != "1" ]; then
errcho "Found $VERSION_COUNT different versions of at $SRC_ITCH_PROJECT:"
errcho $VERSION
exit 1
fi
# -- Fetch build from staging --
echo "$CHANNELS" | while read CHANNEL ; do
butler fetch $SRC_ITCH_PROJECT:$CHANNEL $BUILD_PATH/$CHANNEL
done
# -- Push builds to itch --
echo "$CHANNELS" | while read CHANNEL ; do
butler push $BUILD_PATH/$CHANNEL $DEST_ITCH_PROJECT:$CHANNEL --userversion $VERSION
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment