<commit_before>#!/usr/bin/env bash
#
#

set -e

function usage {
    echo "Usage: $(basename $0) [OPTION]..."
    echo "Build the minecraft docker image"
    echo ""
    echo "  -h, --help               This message."
    echo "  -t, --type RELEASE_TYPE  The release type to build (snapshot, release*)"
    echo ""

}

TYPE='release'

while [[ $# -gt 0 ]]; do
    case $1 in
	-h|--help) usage; exit 1;;
        -t|--type) TYPE=${2}; shift;;
    esac
    shift
done

# get latest release version
version=$(curl -fsSL https://launchermeta.mojang.com/mc/game/version_manifest.json \
	| python -c "import sys, json; print(json.load(sys.stdin)[\"latest\"][\"$TYPE\"])")

echo "Build Version: $version ($TYPE)"

manifest="$(curl -fsSL "https://s3.amazonaws.com/Minecraft.Download/versions/${version}/${version}.json")"

sha1=$(echo $manifest | python -c 'import sys, json; print(json.load(sys.stdin)["downloads"]["server"]["sha1"])')

docker build -t rcarson/minecraft:${version} \
	     --build-arg MINECRAFT_VERSION=${version} \
	     --build-arg MINECRAFT_SHA=${sha1} .
docker push rcarson/minecraft:${version}

if [[ ${TYPE} == 'release' ]]; then
    docker tag rcarson/minecraft:${version} rcarson/minecraft:latest
    docker push rcarson/minecraft:latest
fi
<commit_msg>added ability to build latest release of minecraft from build.sh, can also build other versions/snapshots<commit_after>#!/usr/bin/env bash
#
#

set -e

function usage {
    echo "Usage: $(basename $0) [OPTION]..."
    echo "Build the minecraft docker image"
    echo ""
    echo "  -h, --help               This message."
    echo "  -t, --type RELEASE_TYPE  The release type to build (snapshot, release*)"
    echo ""

}

TYPE='release'

while [[ $# -gt 0 ]]; do
    case $1 in
	-h|--help) usage; exit 1;;
        --snapshot) TYPE='snapshot';;
	--version) version="$2"; shift;;
    esac
    shift
done

if [[ -z "${version:-}" ]]; then
    # get latest release version
    version=$(curl -fsSL https://launchermeta.mojang.com/mc/game/version_manifest.json \
        | python -c "import sys, json; print(json.load(sys.stdin)[\"latest\"][\"$TYPE\"])")
fi

echo "-+ Build Version: $version ($TYPE)"

# pull any docker images that might exist for this version
docker pull rcarson/minecraft:${version} || true

manifest="$(curl -fsSL "https://s3.amazonaws.com/Minecraft.Download/versions/${version}/${version}.json")" || { echo "error: Bad version (${version})"; exit 1; }


sha1=$(echo $manifest | python -c 'import sys, json; print(json.load(sys.stdin)["downloads"]["server"]["sha1"])')

image_id=$(docker build -q -t rcarson/minecraft:${version} \
	          --build-arg MINECRAFT_VERSION=${version} \
	          --build-arg MINECRAFT_SHA=${sha1} .) || {
    echo "-+ Image rcarson/minecraft:${version} not created"
    exit 1
    }

echo "-+ Image rcarson/minecraft:${version} created ($image_id)"

docker push rcarson/minecraft:${version}

if [[ ${TYPE} == 'release' ]]; then
    docker tag ${image_id} rcarson/minecraft:latest
    docker push rcarson/minecraft:latest
fi

{'fraction_non_alphanumeric': 0.17679921130463358, 'fraction_numerical': 0.006572461386789352, 'mean_word_length': 3.3735632183908044, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '27895', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1025, 'n_words': 265}