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

NPM_PACKAGE_NAME=$(json -f package.json name)
NPM_PACKAGE_VERSION=$(json -f package.json version)

#
# configure git
#
git config --global user.name "tadeploy"
git config --global user.email "<EMAIL>"

#
# generate changelog
#
echo "...generating changelog"
curl -X POST github-changelog-api.herokuapp.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME \
 | json contents > CHANGELOG.md

git add CHANGELOG.md

if [[ -n $(git status --porcelain) ]]; then
  echo "...starting push, CHANGELOG.md is dirty after build"
  git commit -n -m "deploy CHANGELOG.md by $CIRCLE_USERNAME [ci skip]"
  git push origin $CIRCLE_BRANCH
else
  echo "...skipping push, repo is clean after build"
fi

#
# s3 sync
#
SOURCE_DIRECTORY=./dist
S3_BUCKET=ta-stardust-assets

echo "...syncing with s3"
aws s3 sync ${SOURCE_DIRECTORY} s3://${S3_BUCKET}/${NPM_PACKAGE_VERSION}/ --delete --acl public-read

#
# npm publish
#
echo "...checking if $NPM_PACKAGE_NAME@$NPM_PACKAGE_VERSION is already published"

NPM_PUBLISHED_VERSIONS=$(npm view ${NPM_PACKAGE_NAME} versions | sed "s/[][',]//g")
NPM_IS_PUBLISHED=false

for ver in ${NPM_PUBLISHED_VERSIONS[@]}; do
  [[ ${NPM_PACKAGE_VERSION} == ${ver} ]] && NPM_IS_PUBLISHED=true
done

if ${NPM_IS_PUBLISHED}; then
 echo "...$NPM_PACKAGE_NAME@$NPM_PACKAGE_VERSION is already published"
else
 echo "...publishing $NPM_PACKAGE_NAME@$NPM_PACKAGE_VERSION"
 echo "...writing ~/.npmrc"
 echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
 echo "...publishing"
 npm publish
fi

#
# gh-pages
#
echo "...deploying gh-pages"
git push -f $CIRCLE_BRANCH:gh-pages
git checkout gh-pages
gulp docs
git add .
git add -f docs/build

if [[ -n $(git status --porcelain) ]]; then<commit_msg>fix deploy script git config and gh-pages push<commit_after>#!/usr/bin/env bash

NPM_PACKAGE_NAME=$(json -f package.json name)
NPM_PACKAGE_VERSION=$(json -f package.json version)

#
# configure git
#
git config --global user.name "tadeploy"
git config --global user.email "<EMAIL>"
git config --global push.default simple

#
# generate changelog
#
echo "...generating changelog"
curl -X POST github-changelog-api.herokuapp.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME \
 | json contents > CHANGELOG.md

git add CHANGELOG.md

if [[ -n $(git status --porcelain) ]]; then
  echo "...starting push, CHANGELOG.md is dirty after build"
  git commit -n -m "deploy CHANGELOG.md by $CIRCLE_USERNAME [ci skip]"
  git push origin $CIRCLE_BRANCH
else
  echo "...skipping push, repo is clean after build"
fi

#
# s3 sync
#
SOURCE_DIRECTORY=./dist
S3_BUCKET=ta-stardust-assets

echo "...syncing with s3"
aws s3 sync ${SOURCE_DIRECTORY} s3://${S3_BUCKET}/${NPM_PACKAGE_VERSION}/ --delete --acl public-read

#
# npm publish
#
echo "...checking if $NPM_PACKAGE_NAME@$NPM_PACKAGE_VERSION is already published"

NPM_PUBLISHED_VERSIONS=$(npm view ${NPM_PACKAGE_NAME} versions | sed "s/[][',]//g")
NPM_IS_PUBLISHED=false

for ver in ${NPM_PUBLISHED_VERSIONS[@]}; do
  [[ ${NPM_PACKAGE_VERSION} == ${ver} ]] && NPM_IS_PUBLISHED=true
done

if ${NPM_IS_PUBLISHED}; then
 echo "...$NPM_PACKAGE_NAME@$NPM_PACKAGE_VERSION is already published"
else
 echo "...publishing $NPM_PACKAGE_NAME@$NPM_PACKAGE_VERSION"
 echo "...writing ~/.npmrc"
 echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
 echo "...publishing"
 npm publish
fi

#
# gh-pages
#
echo "...deploying gh-pages"
git push -f origin $CIRCLE_BRANCH:gh-pages
git checkout gh-pages
gulp docs
git add .
git add -f docs/build

if [[ -n $(git status --porcelain) ]]; then
{'fraction_non_alphanumeric': 0.14390106801573918, 'fraction_numerical': 0.003372681281618887, 'mean_word_length': 4.441896024464832, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4789886', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1323, 'n_words': 340}