#!/usr/bin/env bash

# Check updated version
if git --no-pager diff --exit-code package.json; then
  echo 'No version update'
  exit 1
fi

# Update lock and rebuild
npm install
npm run build

# Update gh-pages
cp css/perfect-scrollbar.css dist/perfect-scrollbar.min.js docs/

# Create commit message
version=$(node -e "console.log(require('./package.json').version)")
message="v$version

Please refer to Releases for changelog.

https://github.com/utatti/perfect-scrollbar/releases"

# Commit, tag, and show detail and file names
git commit . -m "$message"
git show
git tag $version
git --no-pager show --pretty=format:'%Cred%h %Cgreen%an %Creset%s' --name-status
