build_git.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bash
  2. ### Bash Environment Setup
  3. # http://redsymbol.net/articles/unofficial-bash-strict-mode/
  4. # https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
  5. # set -o xtrace
  6. set -o errexit
  7. set -o errtrace
  8. set -o nounset
  9. set -o pipefail
  10. IFS=$'\n'
  11. REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )"
  12. cd "$REPO_DIR"
  13. source "./.venv/bin/activate"
  14. # Make sure git is clean
  15. if [ -z "$(git status --porcelain)" ] && [[ "$(git branch --show-current)" == "master" ]]; then
  16. git pull
  17. else
  18. echo "[!] Warning: git status is dirty!"
  19. echo " Press Ctrl-C to cancel, or wait 10sec to continue..."
  20. sleep 10
  21. fi
  22. # Bump version number in source
  23. function bump_semver {
  24. echo "$1" | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g'
  25. }
  26. OLD_VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")"
  27. NEW_VERSION="$(bump_semver "$OLD_VERSION")"
  28. echo "[*] Bumping VERSION from $OLD_VERSION to $NEW_VERSION"
  29. contents="$(jq ".version = \"$NEW_VERSION\"" "$REPO_DIR/package.json")" && \
  30. echo "${contents}" > package.json