<commit_before>#!/bin/sh
set -e

TAG=$1

if [ -z $TAG ]; then
    echo "Please specify a tag"
    exit 1
fi

if [ -n "$(git status --porcelain)" ]; then
    echo ". is not clean." >&2
    exit 1
fi

old_version=$(perl -MFile::Slurp=read_file <<EOF
use v5.16;
my \$conf = read_file(q{configure.ac});
\$conf =~ /AC_INIT.+\[(\d+\.\d+\.\d+)\]/;
say \$1;
EOF
)

perl -MFile::Slurp=edit_file -e \
    "edit_file { s/\Q$old_version/$TAG/g } \$_ for qw( configure.ac include/maxminddb.h )"

git add configure.ac include/maxminddb.h
git commit -m "Bumped version to $TAG"

if [ ! -d .gh-pages ]; then
    echo "Checking out gh-pages in .gh-pages"
    git clone -b gh-pages <EMAIL>:maxmind/libmaxminddb.git .gh-pages
    cd .gh-pages
else
    echo "Updating .gh-pages"
    cd .gh-pages
    git pull
fi

if [ -n "$(git status --porcelain)" ]; then
    echo ".gh-pages is not clean" >&2
    exit 1
fi

INDEX=index.md
cat <<EOF > $INDEX
---
layout: default
title: libmaxminddb - a library for working with MaxMind DB files
version: $TAG
---
EOF

cat ../doc/libmaxminddb.md >> $INDEX

MMDBLOOKUP=mmdblookup.md
cat <<EOF > $MMDBLOOKUP
---
layout: default
title: mmdblookup - a utility to look up an IP address in a MaxMind DB file
version: $TAG
---
EOF

cat ../doc/mmdblookup.md >> $MMDBLOOKUP

git commit -m "Updated for $TAG" -a

read -p "Push to origin? (y/n) " SHOULD_PUSH

if [ "$SHOULD_PUSH" != "y" ]; then
    echo "Aborting"
    exit 1
fi

git push

cd ..

git tag -a $TAG
git push --tags
<commit_msg>Push all changes including tags when doing release<commit_after>#!/bin/sh
set -e

TAG=$1

if [ -z $TAG ]; then
    echo "Please specify a tag"
    exit 1
fi

if [ -n "$(git status --porcelain)" ]; then
    echo ". is not clean." >&2
    exit 1
fi

old_version=$(perl -MFile::Slurp=read_file <<EOF
use v5.16;
my \$conf = read_file(q{configure.ac});
\$conf =~ /AC_INIT.+\[(\d+\.\d+\.\d+)\]/;
say \$1;
EOF
)

perl -MFile::Slurp=edit_file -e \
    "edit_file { s/\Q$old_version/$TAG/g } \$_ for qw( configure.ac include/maxminddb.h )"

git add configure.ac include/maxminddb.h
git commit -m "Bumped version to $TAG"

if [ ! -d .gh-pages ]; then
    echo "Checking out gh-pages in .gh-pages"
    git clone -b gh-pages <EMAIL>:maxmind/libmaxminddb.git .gh-pages
    cd .gh-pages
else
    echo "Updating .gh-pages"
    cd .gh-pages
    git pull
fi

if [ -n "$(git status --porcelain)" ]; then
    echo ".gh-pages is not clean" >&2
    exit 1
fi

INDEX=index.md
cat <<EOF > $INDEX
---
layout: default
title: libmaxminddb - a library for working with MaxMind DB files
version: $TAG
---
EOF

cat ../doc/libmaxminddb.md >> $INDEX

MMDBLOOKUP=mmdblookup.md
cat <<EOF > $MMDBLOOKUP
---
layout: default
title: mmdblookup - a utility to look up an IP address in a MaxMind DB file
version: $TAG
---
EOF

cat ../doc/mmdblookup.md >> $MMDBLOOKUP

git commit -m "Updated for $TAG" -a

read -p "Push to origin? (y/n) " SHOULD_PUSH

if [ "$SHOULD_PUSH" != "y" ]; then
    echo "Aborting"
    exit 1
fi

git push

cd ..

git tag -a $TAG
git push --follow-tags

{'fraction_non_alphanumeric': 0.1579815303430079, 'fraction_numerical': 0.007255936675461741, 'mean_word_length': 2.7677018633540373, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '1168840', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1189, 'n_words': 381}