<commit_before>#!/bin/bash

# no tag: stop !
TAG=$2
[ -z "$TAG" ] && error "You must pass tag name"

# Write the token in ~/.config/argoos-github-token to be able to
# - create release
# - upload assets
ARGOOS_GIT_TOKEN=$(cat ~/.config/argoos-github-token)

function error() {
    echo $1
    exit 1
}

# create a release
function createRelease() {
    curl -X POST                                                       \
        -H 'Authorization: token '${ARGOOS_GIT_TOKEN}                  \
        -H 'Accept: application/vnd.github.v3+json'                    \
        -d '{"tag_name": "v1-beta3", "name": "'$TAG'", "draft": true}' \
        https://api.github.com/repos/Smile-SA/argoos/releases
}

# get url to upload binary as asset for that release
function getUploadURL() {
    echo "Get upload..." >&2
    curl -sSL https://api.github.com/repos/Smile-SA/argoos/releases                 \
        -H 'Authorization: token '${ARGOOS_GIT_TOKEN}                               \
        -H 'Accept: application/vnd.github.v3+json'                                 \
        | jq 'to_entries[] | select(.value.tag_name=="'$TAG'") | .value.upload_url' \
        | sed 's/{.*}//'                                                            \
        | sed 's/"//g'
}

# build the release
function build() {
    go build -tags netgo -ldflags '-X main.VERSION='$TAG
    strip argoos
    [ $(./argoos -version) == ${TAG} ] || error "Bad version from argoos -version :: "$(./argoos -version)
}


# Upload to github
function upload() {
    url=$1'?name=argoos-linux-x64_64'
    echo "Sending to "$url >&2
    curl -v -SL                                       \
        -H 'Content-Type: application/octet-stream'   \
        -H 'Accept: application/vnd.github.v3+json'   \
        -H 'Authorization: token '${ARGOOS_GIT_TOKEN} \
        --data-binary @argoos $url
}

case $1 in
    build)
        build;<commit_msg>Fixup compilation to be able to use "scratch" docker image<commit_after>#!/bin/bash

# no tag: stop !
TAG=$2
[ -z "$TAG" ] && error "You must pass tag name"

# Write the token in ~/.config/argoos-github-token to be able to
# - create release
# - upload assets
ARGOOS_GIT_TOKEN=$(cat ~/.config/argoos-github-token)

function error() {
    echo $1
    exit 1
}

# create a release
function createRelease() {
    curl -X POST                                                       \
        -H 'Authorization: token '${ARGOOS_GIT_TOKEN}                  \
        -H 'Accept: application/vnd.github.v3+json'                    \
        -d '{"tag_name": "v1-beta3", "name": "'$TAG'", "draft": true}' \
        https://api.github.com/repos/Smile-SA/argoos/releases
}

# get url to upload binary as asset for that release
function getUploadURL() {
    echo "Get upload..." >&2
    curl -sSL https://api.github.com/repos/Smile-SA/argoos/releases                 \
        -H 'Authorization: token '${ARGOOS_GIT_TOKEN}                               \
        -H 'Accept: application/vnd.github.v3+json'                                 \
        | jq 'to_entries[] | select(.value.tag_name=="'$TAG'") | .value.upload_url' \
        | sed 's/{.*}//'                                                            \
        | sed 's/"//g'
}

# build the release
function build() {
    #go build -tags netgo -ldflags '-X main.VERSION='$TAG
    CGO_ENABLED=0 GOGC=off go build -ldflags '-X main.VERSION='$TAG -a -installsuffix nocgo -o argoos
    strip argoos
    [ $(./argoos -version) == ${TAG} ] || error "Bad version from argoos -version :: "$(./argoos -version)
}


# Upload to github
function upload() {
    url=$1'?name=argoos-linux-x64_64'
    echo "Sending to "$url >&2
    curl -v -SL                                       \
        -H 'Content-Type: application/octet-stream'   \
        -H 'Accept: application/vnd.github.v3+json'   \
        -H 'Authorization: token '${ARGOOS_GIT_TOKEN} \
        --data-binary @argoos $url
}

case $1 in
    build)
        build;
{'fraction_non_alphanumeric': 0.1447633434038268, 'fraction_numerical': 0.008308157099697885, 'mean_word_length': 1.6522029372496663, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4285023', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1251, 'n_words': 316}