<commit_before>#!/bin/bash

set -ex

GO_LDFLAGS="-X main.version=`git describe --tags --exact-match || git rev-parse --short HEAD` -X main.commit=`git rev-parse --short HEAD`"
BIN_NAME=$(basename `pwd`)
PLATFORMS="darwin linux windows"
rm -rf releases/ && mkdir releases
for PLATFORM in $PLATFORMS; do
  BIN_NAME_F=$BIN_NAME
  if [ $PLATFORM == "windows" ]; then
    BIN_NAME_F="${BIN_NAME}.exe"
  fi
  CGO_ENABLED=0 GOOS=${PLATFORM} go build -a -tags netgo -installsuffix netgo -ldflags "$GO_LDFLAGS" -o "${BIN_NAME_F}" && zip "releases/${BIN_NAME}-${PLATFORM}-amd64.zip" "${BIN_NAME_F}" && rm "${BIN_NAME_F}"
done
ls -alF releases/<commit_msg>Update release.sh<commit_after>#!/bin/bash

set -e

# Run tests
./test.sh

# Initialize required variables
BIN_NAME=$(basename `pwd`)
BIN_VERSION=`git describe --tags --exact-match || git rev-parse --short HEAD || exit 1`
GIT_COMMIT=`git rev-parse --short HEAD || exit 1`
PLATFORMS="darwin linux windows"
ARCHS="amd64"
GO_LDFLAGS="-X main.version=${BIN_VERSION} -X main.commit=${GIT_COMMIT}"
GO_CGO_ENABLED=0

# Prepare release files
mkdir -p releases && rm -rf releases/*.*
echo "release for ${BIN_NAME} ${BIN_VERSION} (${GIT_COMMIT})"
if [ "${BIN_VERSION:0:1}" != "v" ]; then
  echo "no release since current commit ${BIN_VERSION} is not a version tag"
  exit 0
fi

# Iterate platforms
for PLATFORM in $PLATFORMS; do
  BIN_NAME_F=$BIN_NAME
  if [ $PLATFORM == "windows" ]; then
    BIN_NAME_F="${BIN_NAME}.exe"
  fi
  for ARCH in $ARCHS; do
    echo "preparing ${BIN_NAME}-${PLATFORM}-${ARCH}.zip"

    GOOS=${PLATFORM} GOARCH=${ARCH} CGO_ENABLED=${GO_CGO_ENABLED} \
    go build -a -tags netgo -installsuffix netgo -ldflags "$GO_LDFLAGS" -o "${BIN_NAME_F}" && \
    zip "releases/${BIN_NAME}-${PLATFORM}-${ARCH}.zip" "${BIN_NAME_F}" && \
    rm "${BIN_NAME_F}"
  done
done
ls -alF releases/
{'fraction_non_alphanumeric': 0.1702937976060936, 'fraction_numerical': 0.005984766050054407, 'mean_word_length': 4.456973293768546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3126932', 'n_tokens_mistral': 714, 'n_tokens_neox': 689, 'n_words': 177}