<commit_before>#!/bin/sh

set -ex

thisversion=$(grep '^define(\[thisversion\],\[' configure.ac | cut -d '[' -f 3 | cut -d ']' -f 1)
nextversion=$(grep '^define(\[nextversion\],\[' configure.ac | cut -d '[' -f 3 | cut -d ']' -f 1)
if [ x"$thisversion" = x"$nextversion" ]; then
	echo >&2 "Please bump nextversion in configure.ac first!"
	echo >&2 "Follow semantic versioning when doing so."
	echo >&2 "Changes since last version:"
	git log v"$thisversion".. >&2
	exit 1
fi

# Inform caller about semver requirements.
if git grep "REMOVE IN v${nextversion%%.*}\\>" .; then
	echo >&2 'Stuff to do before next semver!'
	exit 1
fi

# Are we on master?
if [ x"$(git rev-parse --abbrev-ref HEAD)" != x'master' ]; then
	echo >&2 'Must be on master.'
	exit 1
fi

# Bump the version.
sed -i -e '
	s/^define(\[thisversion\],\[.*/define([thisversion],['"$nextversion"'])/
' configure.ac

# Generate a tarball.
tardir=xsecurelock-$nextversion
tarball=$tardir.tar.gz
rm -f "$tarball"
./config.status --recheck
make clean
rm -f version.c
make dist GIT_VERSION=v$nextversion
ls -l "$tarball"

# Extra stuff added by "make dist".
tar_extra="<commit_msg>Make release building work on a fresh tree.<commit_after>#!/bin/sh

set -ex

thisversion=$(grep '^define(\[thisversion\],\[' configure.ac | cut -d '[' -f 3 | cut -d ']' -f 1)
nextversion=$(grep '^define(\[nextversion\],\[' configure.ac | cut -d '[' -f 3 | cut -d ']' -f 1)
if [ x"$thisversion" = x"$nextversion" ]; then
	echo >&2 "Please bump nextversion in configure.ac first!"
	echo >&2 "Follow semantic versioning when doing so."
	echo >&2 "Changes since last version:"
	git log v"$thisversion".. >&2
	exit 1
fi

# Inform caller about semver requirements.
if git grep "REMOVE IN v${nextversion%%.*}\\>" .; then
	echo >&2 'Stuff to do before next semver!'
	exit 1
fi

# Are we on master?
if [ x"$(git rev-parse --abbrev-ref HEAD)" != x'master' ]; then
	echo >&2 'Must be on master.'
	exit 1
fi

# Bump the version.
sed -i -e '
	s/^define(\[thisversion\],\[.*/define([thisversion],['"$nextversion"'])/
' configure.ac

# Generate a tarball.
tardir=xsecurelock-$nextversion
tarball=$tardir.tar.gz
rm -f "$tarball"
sh autogen.sh
./config.status --recheck || ./configure --with-pam-service-name=common-auth
make clean
rm -f version.c
make dist GIT_VERSION=v$nextversion
ls -l "$tarball"

# Extra stuff added by "make dist".
tar_extra="
{'fraction_non_alphanumeric': 0.1794005909666526, 'fraction_numerical': 0.010975094976783452, 'mean_word_length': 3.8466257668711656, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '4463873', 'n_tokens_mistral': 900, 'n_tokens_neox': 859, 'n_words': 284}