Skip to content

Instantly share code, notes, and snippets.

@x-zvf
Last active January 31, 2023 10:02
Show Gist options
  • Save x-zvf/7c5527c591583217e6d06deed2459c57 to your computer and use it in GitHub Desktop.
Save x-zvf/7c5527c591583217e6d06deed2459c57 to your computer and use it in GitHub Desktop.
Simple update script to update kit-sqd/programming-lecture-artemis
#!/bin/sh
set -e
PLATFORM="Linux_x86_64"
REPO="kit-sdq/programming-lecture-eclipse-artemis"
TYPE="Grading"
OUTPUTDIR="eclipse"
FILENAME="eclipse.zip"
echo "Updating $REPO type $TYPE for $PLATFORM in $OUTPUTDIR"
URL="$(curl -s https://api.github.com/repos/$REPO/releases/latest | grep "browser_download_url" | grep "$TYPE" | grep "$PLATFORM" | cut -d '"' -f 4)"
VERSION="$(echo "$URL" | cut -d '/' -f 8)"
echo "Github current version: $VERSION"
VERSIONFILE="$OUTPUTDIR/.gh-version.txt"
if [ -f "$VERSIONFILE" ]; then
if grep -q "$VERSION" "$VERSIONFILE"; then
echo "Already up to date."
exit 0
else
echo "Local version is out of date"
fi
else
echo "Warning: Version file $VERSIONFILE does not exist."
fi
echo "Downloading release."
curl -L -o "$FILENAME" "$URL"
rm -rf "$OUTPUTDIR"
unzip -d "$OUTPUTDIR" "$FILENAME"
echo "$VERSION" > "$VERSIONFILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment