<commit_before>#!/bin/sh

make_docs() {
  rm -f docs-source/smartsheet.rst
  rm -f docs-source/smartsheet.models.rst
  rm -f docs-source/modules.rst
  sphinx-apidoc -o docs-source smartsheet
  rm -rf docs-source/_build
  sphinx-build -b html -d docs-source/_build/doctrees docs-source/. docs-source/_build/html
  rm -rf docs
  cp -a docs-source/_build/html docs/
  cp .nojekyll docs
}

install_packages() {
  pip install -U sphinx
  pip install sphinx_rtd_theme
  pip install setuptools-scm
  pip install gitchangelog mako
  pip install collective.checkdocs
  pip install twine
}

set -e
export RELEASE_TAG=${deploy}
install_packages
echo "beginning deploy..."

# git configuration
git config --global user.email "<EMAIL>"
git config --global user.name "Automated Build"

echo "docs 1st pass..."
make_docs
git add docs/*
git commit -am "docs: build ${RELEASE_TAG} docs 1st pass"
git push https://${GH_USER}:${GH_ACCESS_TOKEN}@github.com/smartsheet-platform/smartsheet-python-sdk.git \
    HEAD:${TRAVIS_BRANCH} > /dev/null 2>&1

echo "updating release tag..."
git tag ${RELEASE_TAG} -m "Release ${RELEASE_TAG}"
git push https://${GH_USER}:${GH_ACCESS_TOKEN}@github.com/smartsheet-platform/smartsheet-python-sdk.git \
    HEAD:${TRAVIS_BRANCH} --tags > /dev/null 2>&1

echo "building distribution..."
# note this must be done immediately after the tag and before other files are committed
# to avoid setuptools_scm from designating the distribution with an interim dev tag.
python setup.py checkdocs
python setup.py sdist bdist_wheel
echo "uploading distribution..."
twine upload -u "smartsheet-platform" -p ${PYPI_PASSWORD} dist/*

echo "docs final pass..."
make_docs
git add docs/*
git commit -am "docs: build ${RELEASE_TAG} final docs"
git push https://${GH_USER}:${GH_ACCESS_TOKEN}@github.com/smartsheet-platform/smartsheet-python-sdk.git \
    HEAD:${TRAVIS_BRANCH} > /dev/null 2>&1
echo "update CHANGELOG.md..."

gitchangelog
git add CHANGELOG.md
git commit -am "docs: update CHANGELOG.md"
git push https://${GH_USER}:${GH_ACCESS_TOKEN}@github.com/smartsheet-platform/smartsheet-python-sdk.git \
    HEAD:${TRAVIS_BRANCH} > /dev/null 2>&1<commit_msg>chg: automated doc updates should be ignored in changelist<commit_after>#!/bin/sh

make_docs() {
  rm -f docs-source/smartsheet.rst
  rm -f docs-source/smartsheet.models.rst
  rm -f docs-source/modules.rst
  sphinx-apidoc -o docs-source smartsheet
  rm -rf docs-source/_build
  sphinx-build -b html -d docs-source/_build/doctrees docs-source/. docs-source/_build/html
  rm -rf docs
  cp -a docs-source/_build/html docs/
  cp .nojekyll docs
}

install_packages() {
  pip install -U sphinx
  pip install sphinx_rtd_theme
  pip install setuptools-scm
  pip install gitchangelog mako
  pip install collective.checkdocs
  pip install twine
}

set -e
export RELEASE_TAG=${deploy}
install_packages
echo "beginning deploy..."

# git configuration
git config --global user.email "<EMAIL>"
git config --global user.name "Automated Build"

echo "docs 1st pass..."
make_docs
git add docs/*
git commit -am "doc: build ${RELEASE_TAG} docs 1st pass"
git push https://${GH_USER}:${GH_ACCESS_TOKEN}@github.com/smartsheet-platform/smartsheet-python-sdk.git \
    HEAD:${TRAVIS_BRANCH} > /dev/null 2>&1

echo "updating release tag..."
git tag ${RELEASE_TAG} -m "Release ${RELEASE_TAG}"
git push https://${GH_USER}:${GH_ACCESS_TOKEN}@github.com/smartsheet-platform/smartsheet-python-sdk.git \
    HEAD:${TRAVIS_BRANCH} --tags > /dev/null 2>&1

echo "building distribution..."
# note this must be done immediately after the tag and before other files are committed
# to avoid setuptools_scm from designating the distribution with an interim dev tag.
python setup.py checkdocs
python setup.py sdist bdist_wheel
echo "uploading distribution..."
twine upload -u "smartsheet-platform" -p ${PYPI_PASSWORD} dist/*

echo "docs final pass..."
make_docs
git add docs/*
git commit -am "doc: build ${RELEASE_TAG} final docs"
git push https://${GH_USER}:${GH_ACCESS_TOKEN}@github.com/smartsheet-platform/smartsheet-python-sdk.git \
    HEAD:${TRAVIS_BRANCH} > /dev/null 2>&1
echo "update CHANGELOG.md..."

gitchangelog
git add CHANGELOG.md
git commit -am "doc: update CHANGELOG.md"
git push https://${GH_USER}:${GH_ACCESS_TOKEN}@github.com/smartsheet-platform/smartsheet-python-sdk.git \
    HEAD:${TRAVIS_BRANCH} > /dev/null 2>&1
{'fraction_non_alphanumeric': 0.12522977941176472, 'fraction_numerical': 0.004595588235294118, 'mean_word_length': 4.23826714801444, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 8, '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': '1480765', 'n_tokens_mistral': 1558, 'n_tokens_neox': 1471, 'n_words': 417}