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

REL_SCRIPT_DIR="`dirname \"$0\"`"
SCRIPT_DIR="`( cd \"$REL_SCRIPT_DIR\" && pwd )`"

case "$OSTYPE" in
    darwin*) PLATFORM="OSX" ;;
    linux*)  PLATFORM="LINUX" ;;
    bsd*)    PLATFORM="BSD" ;;
    *)       PLATFORM="UNKNOWN" ;;
esac

release_python()
{
    cd $SCRIPT_DIR/..
    git clean -xfd || exit 1
    git fetch --all || exit 1

    git checkout -B staging/release origin/staging/release
    git clean -xfd || exit 1
    cd python
    # python setup.py register -r pypi
    cp setup-js.py setup.py || exit 1
    python setup.py sdist || exit 1
    cp setup-css.py setup.py || exit 1
    python setup.py sdist || exit 1
    rm setup.py || exit 1
    python -m twine upload dist/* || exit 1
}

release_node()
{
    cd $SCRIPT_DIR/..
    git clean -xfd || exit 1
    git fetch --all || exit 1

    git checkout -B staging/release origin/staging/release
    git clean -xfd || exit 1
    unset NPM_TAG
    if [[ $NEW_VERSION =~ .*(rc|beta).* ]]; then
    NPM_TAG='--tag next'
    fi
    $SCRIPT_DIR/npm publish . $NPM_TAG || exit 1
}

release_web()
{
    cd $SCRIPT_DIR/..
    git clean -xfd || exit 1
    git fetch --all || exit 1

    git checkout -B staging/gh-pages site/staging/gh-pages || exit 1
    git reset --hard site/gh-pages || exit 1
    git merge origin/staging/release --no-edit || exit 1
    git push || exit 1

    git checkout -B staging/main site/staging/main || exit 1
    git reset --hard site/main || exit 1
    git merge origin/staging/main --no-edit || exit 1
    git push || exit 1    
}

sedi() {
    if [[ "$PLATFORM" == "OSX" || "$PLATFORM" == "BSD" ]]; then
        sed -i "" $@
    elif [ "$PLATFORM" == "LINUX" ]; then
        sed -i $@
    else
        exit 1
    fi
}

update_versions()
{
    cd $SCRIPT_DIR/..
    git clean -xfd || exit 1
    git fetch --all || exit 1

    # trigger remote uses deploy key, push will cause downstream GitHub Actions to fire
    git checkout -B staging/main trigger/staging/main || exit 1
    git merge origin/main --no-edit || exit 1
    git clean -xfd || exit 1

    $SCRIPT_DIR/generate-changelog.sh beautify-web/js-beautify $GITHUB_TOKEN || exit 1

    $SCRIPT_DIR/npm version --no-git-tag-version $NEW_VERSION || exit 1

    sedi -E 's@(cdn.rawgit.+beautify/v)[^/]+@\1'$NEW_VERSION'@' README.md
    sedi -E 's@(cdnjs.cloudflare.+beautify/)[^/]+@\1'$NEW_VERSION'@' README.md
    sedi -E 's/\((README\.md:.js-beautify@).+\)/(\1'$NEW_VERSION')/' README.md

    echo "__version__ = \"$NEW_VERSION\"" > python/jsbeautifier/__version__.py
    echo "__version__ = \"$NEW_VERSION\"" > python/cssbeautifier/__version__.py
    git add . || exit 1
    git commit -am "Bump version numbers for $NEW_VERSION" || exit 1
    git push || exit 1
}

update_release_branch()
{
    cd $SCRIPT_DIR/..
    git clean -xfd || exit 1
    git fetch --all || exit 1

    git reset --hard
    # trigger remote uses deploy key, push will cause downstream GitHub Actions to fire
    git checkout -B staging/release trigger/staging/release || exit 1
    git merge origin/release --no-edit || exit 1
    git merge origin/staging/main --no-edit || exit 1

    make js || exit 1
    git add -f js/lib/ || exit 1
    git add . 
    git commit -m "Release: $NEW_VERSION"
    git tag "v$NEW_VERSION" || exit 1
    git push || exit 1
    git push --tags
}

main()<commit_msg>Add generated test files to release branch<commit_after>#!/usr/bin/env bash

REL_SCRIPT_DIR="`dirname \"$0\"`"
SCRIPT_DIR="`( cd \"$REL_SCRIPT_DIR\" && pwd )`"

case "$OSTYPE" in
    darwin*) PLATFORM="OSX" ;;
    linux*)  PLATFORM="LINUX" ;;
    bsd*)    PLATFORM="BSD" ;;
    *)       PLATFORM="UNKNOWN" ;;
esac

release_python()
{
    cd $SCRIPT_DIR/..
    git clean -xfd || exit 1
    git fetch --all || exit 1

    git checkout -B staging/release origin/staging/release
    git clean -xfd || exit 1 
    cd python
    # python setup.py register -r pypi
    cp setup-js.py setup.py || exit 1
    python setup.py sdist || exit 1
    cp setup-css.py setup.py || exit 1
    python setup.py sdist || exit 1
    rm setup.py || exit 1
    python -m twine upload dist/* || exit 1
}

release_node()
{
    cd $SCRIPT_DIR/..
    git clean -xfd || exit 1
    git fetch --all || exit 1

    git checkout -B staging/release origin/staging/release
    git clean -xfd || exit 1
    unset NPM_TAG
    if [[ $NEW_VERSION =~ .*(rc|beta).* ]]; then
    NPM_TAG='--tag next'
    fi
    $SCRIPT_DIR/npm publish . $NPM_TAG || exit 1
}

release_web()
{
    cd $SCRIPT_DIR/..
    git clean -xfd || exit 1
    git fetch --all || exit 1

    git checkout -B staging/gh-pages site/staging/gh-pages || exit 1
    git reset --hard site/gh-pages || exit 1
    git merge origin/staging/release --no-edit || exit 1
    git push || exit 1

    git checkout -B staging/main site/staging/main || exit 1
    git reset --hard site/main || exit 1
    git merge origin/staging/main --no-edit || exit 1
    git push || exit 1    
}

sedi() {
    if [[ "$PLATFORM" == "OSX" || "$PLATFORM" == "BSD" ]]; then
        sed -i "" $@
    elif [ "$PLATFORM" == "LINUX" ]; then
        sed -i $@
    else
        exit 1
    fi
}

update_versions()
{
    cd $SCRIPT_DIR/..
    git clean -xfd || exit 1
    git fetch --all || exit 1

    # trigger remote uses deploy key, push will cause downstream GitHub Actions to fire
    git checkout -B staging/main trigger/staging/main || exit 1
    git merge origin/main --no-edit || exit 1
    git clean -xfd || exit 1

    $SCRIPT_DIR/generate-changelog.sh beautify-web/js-beautify $GITHUB_TOKEN || exit 1

    $SCRIPT_DIR/npm version --no-git-tag-version $NEW_VERSION || exit 1

    sedi -E 's@(cdn.rawgit.+beautify/v)[^/]+@\1'$NEW_VERSION'@' README.md
    sedi -E 's@(cdnjs.cloudflare.+beautify/)[^/]+@\1'$NEW_VERSION'@' README.md
    sedi -E 's/\((README\.md:.js-beautify@).+\)/(\1'$NEW_VERSION')/' README.md

    echo "__version__ = \"$NEW_VERSION\"" > python/jsbeautifier/__version__.py
    echo "__version__ = \"$NEW_VERSION\"" > python/cssbeautifier/__version__.py
    git add . || exit 1
    git commit -am "Bump version numbers for $NEW_VERSION" || exit 1
    git push || exit 1
}

update_release_branch()
{
    cd $SCRIPT_DIR/..
    git clean -xfd || exit 1
    git fetch --all || exit 1

    git reset --hard
    # trigger remote uses deploy key, push will cause downstream GitHub Actions to fire
    git checkout -B staging/release trigger/staging/release || exit 1
    git merge origin/release --no-edit || exit 1
    git merge origin/staging/main --no-edit || exit 1

    make js || exit 1
    git add -f js/lib/ || exit 1
    git add -f js/test/generated/
    git add -f python/jsbeautifier/tests/generated/
    git add -f python/cssbeautifier/tests/generated/
    
    git commit -m "Release: $NEW_VERSION"
    git tag "v$NEW_VERSION" || exit 1
    git push || exit 1
    git push --tags
}

main()
{'fraction_non_alphanumeric': 0.14214900131214464, 'fraction_numerical': 0.013704621664965739, 'mean_word_length': 2.419740777666999, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5408555', 'n_tokens_mistral': 2582, 'n_tokens_neox': 2379, 'n_words': 747}