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

if ! [[ $1 =~ [0-9\.\-] ]]; then
    echo 'invalid version number'
    exit 1
fi

VERSION="$1"
SHORT_VERSION=`echo ${VERSION} | cut -f1 -d"-"`
PROJECT_NAME='setwp'
PROJECT_PATH="github.com/alexandrecormier/${PROJECT_NAME}"
PROJECT_FULL_PATH="${GOPATH}/src/${PROJECT_PATH}"
BINARY_PATH="${GOPATH}/bin"
TARBALL="${PROJECT_FULL_PATH}/releases/${PROJECT_NAME}-v${VERSION}.tar.gz"
BREW_FORMULA="${PROJECT_FULL_PATH}/homebrew/${PROJECT_NAME}.rb"
BREW_FORMULA_TEMPLATE="${BREW_FORMULA}.template"
ARGS_FILE="${PROJECT_FULL_PATH}/args/args.go"

# Bump version
sed -E -i '' "s/version [0-9\.]+/version ${SHORT_VERSION}/" "${ARGS_FILE}"

# Build
go install "${PROJECT_PATH}"

# Make tarballs
mkdir -p releases
tar -czf "${TARBALL}" completion/* -C "${BINARY_PATH}" "${PROJECT_NAME}"

# Update homebrew formula
SHA256_HASH=`openssl dgst -sha256 ${TARBALL} | xxd -ps | tr -d '\n'`
sed -e "s/<VERSION>/${VERSION}/g" \
    -e "s/<SHA256_HASH>/${SHA256_HASH}/" \
    "${BREW_FORMULA_TEMPLATE}" > "${BREW_FORMULA}"<commit_msg>fix sha256 hash in packaging script<commit_after>#!/usr/bin/env bash

if ! [[ $1 =~ [0-9\.\-] ]]; then
    echo 'invalid version number'
    exit 1
fi

VERSION="$1"
SHORT_VERSION=`echo ${VERSION} | cut -f1 -d"-"`
PROJECT_NAME='setwp'
PROJECT_PATH="github.com/alexandrecormier/${PROJECT_NAME}"
PROJECT_FULL_PATH="${GOPATH}/src/${PROJECT_PATH}"
BINARY_PATH="${GOPATH}/bin"
TARBALL="${PROJECT_FULL_PATH}/releases/${PROJECT_NAME}-v${VERSION}.tar.gz"
BREW_FORMULA="${PROJECT_FULL_PATH}/homebrew/${PROJECT_NAME}.rb"
BREW_FORMULA_TEMPLATE="${BREW_FORMULA}.template"
ARGS_FILE="${PROJECT_FULL_PATH}/args/args.go"

# Bump version
sed -E -i '' "s/version [0-9\.]+/version ${SHORT_VERSION}/" "${ARGS_FILE}"

# Build
go install "${PROJECT_PATH}"

# Make tarballs
mkdir -p releases
tar -czf "${TARBALL}" completion/* -C "${BINARY_PATH}" "${PROJECT_NAME}"

# Update homebrew formula
SHA256_HASH=`openssl dgst -sha256 ${TARBALL} | cut -f2 -d" "`
sed -e "s/<VERSION>/${VERSION}/g" \
    -e "s/<SHA256_HASH>/${SHA256_HASH}/" \
    "${BREW_FORMULA_TEMPLATE}" > "${BREW_FORMULA}"
{'fraction_non_alphanumeric': 0.20617577197149645, 'fraction_numerical': 0.020902612826603325, 'mean_word_length': 5.440366972477064, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '5659646', 'n_tokens_mistral': 888, 'n_tokens_neox': 844, 'n_words': 144}