<commit_before>#!/bin/bash

set -ueo pipefail

# Check the environment
if ! which jq >/dev/null 2>/dev/null; then
    echo "The release script requires jq (https://stedolan.github.io/jq/) to run."
    echo "Ideas: "
    echo
    echo "    brew install jq"
    echo "    apt-get install jq"
    exit 1
fi

if [[ "$(uname)" == 'Darwin' ]]; then
    if ! which gdate >/dev/null 2>/dev/null; then
        echo "It appears you're on OSX and don't have GNU Coreutils installed, which is required by this release script."
        echo "Please install it and re-run this script:"
        echo
        echo "    brew install coreutils"
        exit 1
    fi
    date=gdate
else
    date=date
fi

# Constants
api="https://quay.io/api/v1"
started_at=$($date +%s)

## Read input and env
release_tag="$1"
# Service images
images="${IMAGES:-zipkin-cassandra zipkin-elasticsearch zipkin-elasticsearch5 zipkin-kafka zipkin-ui zipkin-mysql zipkin}"
dirs="${DIRS:-cassandra elasticsearch elasticsearch5 kafka zipkin-ui mysql zipkin}"
# Remotes, auth
docker_organization="${DOCKER_ORGANIZATION:-openzipkin}"
quayio_oauth2_token="$QUAYIO_OAUTH2_TOKEN"
git_remote="${GIT_REMOTE:-origin}"
target_git_branch="${TARGET_GIT_BRANCH:-master}"

prefix() {
    while read line; do
        echo "[$($date +"%x %T")][${1}] $line"
    done
}

checkout-target-branch () {
    git fetch "$git_remote" "$target_git_branch"
    git checkout -B "$target_git_branch"
}

bump-zipkin-version () {
    local version="$1"; shift
    local images="$@"
    local modified=false

    for image in $images; do
        echo "Bumping ZIPKIN_VERSION in the Dockerfile of $image..."
        dockerfile="${image}/Dockerfile"
        sed -i.bak -e "s/ENV ZIPKIN_VERSION .*/ENV ZIPKIN_VERSION ${version}/" "$dockerfile"
        if ! diff "${dockerfile}.bak" "${dockerfile}" > /dev/null; then
            modified=true
        fi
        rm "${dockerfile}.bak"
        git add "$dockerfile"
    done

    if "$modified"; then
        git commit -m "Bump ZIPKIN_VERSION to $version"
        git push
    else
        echo "ZIPKIN_VERSION was already ${version}, no commit to make"
    fi
}

create-and-push-tag () {
    local tag="$1"
    echo "Creating and pushing tag $tag..."
    git tag "$tag" --force
    git push "$git_remote" "$tag" --force
}

fetch-last-build () {
    local tag="$1"
    local image="$2"
    local repo="${docker_organization}/${image}"
<commit_msg>Add --set-upstream to git push, fixing build on git 2<commit_after>#!/bin/bash

set -ueo pipefail

# Check the environment
if ! which jq >/dev/null 2>/dev/null; then
    echo "The release script requires jq (https://stedolan.github.io/jq/) to run."
    echo "Ideas: "
    echo
    echo "    brew install jq"
    echo "    apt-get install jq"
    exit 1
fi

if [[ "$(uname)" == 'Darwin' ]]; then
    if ! which gdate >/dev/null 2>/dev/null; then
        echo "It appears you're on OSX and don't have GNU Coreutils installed, which is required by this release script."
        echo "Please install it and re-run this script:"
        echo
        echo "    brew install coreutils"
        exit 1
    fi
    date=gdate
else
    date=date
fi

# Constants
api="https://quay.io/api/v1"
started_at=$($date +%s)

## Read input and env
release_tag="$1"
# Service images
images="${IMAGES:-zipkin-cassandra zipkin-elasticsearch zipkin-elasticsearch5 zipkin-kafka zipkin-ui zipkin-mysql zipkin}"
dirs="${DIRS:-cassandra elasticsearch elasticsearch5 kafka zipkin-ui mysql zipkin}"
# Remotes, auth
docker_organization="${DOCKER_ORGANIZATION:-openzipkin}"
quayio_oauth2_token="$QU<PASSWORD>"
git_remote="${GIT_REMOTE:-origin}"
target_git_branch="${TARGET_GIT_BRANCH:-master}"

prefix() {
    while read line; do
        echo "[$($date +"%x %T")][${1}] $line"
    done
}

checkout-target-branch () {
    git fetch "$git_remote" "$target_git_branch"
    git checkout -B "$target_git_branch"
}

bump-zipkin-version () {
    local version="$1"; shift
    local images="$@"
    local modified=false

    for image in $images; do
        echo "Bumping ZIPKIN_VERSION in the Dockerfile of $image..."
        dockerfile="${image}/Dockerfile"
        sed -i.bak -e "s/ENV ZIPKIN_VERSION .*/ENV ZIPKIN_VERSION ${version}/" "$dockerfile"
        if ! diff "${dockerfile}.bak" "${dockerfile}" > /dev/null; then
            modified=true
        fi
        rm "${dockerfile}.bak"
        git add "$dockerfile"
    done

    if "$modified"; then
        git commit -m "Bump ZIPKIN_VERSION to $version"
        git push --set-upstream $git_remote $target_git_branch
    else
        echo "ZIPKIN_VERSION was already ${version}, no commit to make"
    fi
}

create-and-push-tag () {
    local tag="$1"
    echo "Creating and pushing tag $tag..."
    git tag "$tag" --force
    git push "$git_remote" "$tag" --force
}

fetch-last-build () {
    local tag="$1"
    local image="$2"
    local repo="${docker_organization}/${image}"

{'fraction_non_alphanumeric': 0.1368720764693919, 'fraction_numerical': 0.006101281269066504, 'mean_word_length': 2.9886455798864557, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 14, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2909885', 'n_tokens_mistral': 1680, 'n_tokens_neox': 1619, 'n_words': 470}