<commit_before>#!/usr/bin/sh
PATH=$PATH:$PWD/node_modules/.bin

RELEASE_BRANCH=$1
NEW_VERSION=$2

ROOT=$(dirname $(readlink -f $0))/..
INITIAL_BRANCH=$(git rev-parse --abbrev-ref HEAD)

main() {
  ensure_clean_index &&
    check_args &&
    bump_version &&
    merge_to_release &&
    run_tests &&
    run_build &&
    bootstrap &&
    commit_and_tag &&
    push_and_publish &&

  # leave the release branch
  quit
}

ensure_clean_index() {
  echo_funcname

  # make sure the repo is clean
  git clean -fx dist/*
  if ! git diff-index HEAD --stat --exit-code; then
    echo
    quit "working directory must be clean" $?
  fi
}

check_args() {
  echo_funcname

  if [[ -z $RELEASE_BRANCH ]] | [[ -z $NEW_VERSION ]]; then
    quit "Missing args. Usage: release.sh release_branch new_version" 1
  fi
}

bump_version() {
  echo_funcname

  npx lerna version --no-git-tag-version --exact $NEW_VERSION ||
    quit "failed to bump version" 1

  # copy license file
  npx lerna exec --no-private -- cp -v $ROOT/LICENSE . ||
    quit "failed to copy LICENSE"

  NEW_VERSION=$(node $ROOT/scripts/version.js)
  NEW_TAG="v$(semver clean $NEW_VERSION)"

  # if the version tag already exists
  if [[ $(git tag -l $NEW_TAG) == $NEW_TAG ]]; then
    quit "$NEW_TAG tag already exists" 1
  fi

  git add .
  git commit -m "chore: bump version to ${NEW_VERSION}"
}

merge_to_release() {
  echo_funcname

  echo "checking out the '$RELEASE_BRANCH' branch"
  git checkout $RELEASE_BRANCH || exit $?
  git pull --ff-only

  # clean repo
  npx tsc --build --clean $ROOT
  git clean -fdX


  git merge --no-ff --no-edit $INITIAL_BRANCH || quit "failed to merge branches" $?
  npm run bootstrap || quit "bootstrapping failed" $?
}

run_tests() {
  echo_funcname

  npm run tsc_lint_test || quit "tests have failed" $?
}

run_build() {
  echo_funcname

  # copy README
  cp $ROOT/README.md packages/interactjs/ &&

  # generate .js and .d.ts files<commit_msg>chore: don't bump version during release<commit_after>#!/usr/bin/sh
PATH=$PATH:$PWD/node_modules/.bin

RELEASE_BRANCH=$1
NEW_VERSION=$2

ROOT=$(dirname $(readlink -f $0))/..
INITIAL_BRANCH=$(git rev-parse --abbrev-ref HEAD)

main() {
  ensure_clean_index &&
    check_args &&
    check_version &&
    merge_to_release &&
    run_tests &&
    run_build &&
    bootstrap &&
    commit_and_tag &&
    push_and_publish &&

  # leave the release branch
  quit
}

ensure_clean_index() {
  echo_funcname

  # make sure the repo is clean
  git clean -fx dist/*
  if ! git diff-index HEAD --stat --exit-code; then
    echo
    quit "working directory must be clean" $?
  fi
}

check_args() {
  echo_funcname

  if [[ -z $RELEASE_BRANCH ]]; then
    quit "Missing release branch arg" 1
  fi
}

check_version() {
  echo_funcname

  NEW_VERSION=$(node $ROOT/scripts/version.js)
  NEW_TAG="v$(semver clean $NEW_VERSION)"

  # if the version tag already exists
  if [[ $(git tag -l $NEW_TAG) == $NEW_TAG ]]; then
    quit "$NEW_TAG tag already exists" 1
  fi
}

merge_to_release() {
  echo_funcname

  echo "checking out the '$RELEASE_BRANCH' branch"
  git checkout $RELEASE_BRANCH || exit $?
  git pull --ff-only

  # clean repo
  npx tsc --build --clean $ROOT
  git clean -fdX


  git merge --no-ff --no-edit $INITIAL_BRANCH || quit "failed to merge branches" $?
  npm run bootstrap || quit "bootstrapping failed" $?
}

run_tests() {
  echo_funcname

  npm run tsc_lint_test || quit "tests have failed" $?
}

run_build() {
  echo_funcname

  # copy README
  cp $ROOT/README.md packages/interactjs/ &&

  # copy license file
  npx lerna exec --no-private -- cp -v $ROOT/LICENSE . ||
    quit "failed to copy LICENSE"

  # generate .js and .d.ts files
{'fraction_non_alphanumeric': 0.1247276688453159, 'fraction_numerical': 0.0029956427015250544, 'mean_word_length': 3.1131019036954086, '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': '722450', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1283, 'n_words': 372}