circle-release-next-packages.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. function parse_git_hash() {
  3. git rev-parse --short HEAD 2> /dev/null | sed "s/\(.*\)/\1/"
  4. }
  5. function prapare_version_commit () {
  6. echo $'\nCommiting version changes. This commit will not be checked-in!'
  7. git config --global user.email "circleci@grafana.com"
  8. git config --global user.name "CirceCI"
  9. git commit -am "Version commit"
  10. }
  11. #Get current version from lerna.json
  12. PACKAGE_VERSION=$(grep '"version"' lerna.json | cut -d '"' -f 4)
  13. # Get short current commit's has
  14. GIT_SHA=$(parse_git_hash)
  15. echo "Commit: ${GIT_SHA}"
  16. echo "Current lerna.json version: ${PACKAGE_VERSION}"
  17. # check if there were any changes to packages between current and previous commit
  18. count=$(git diff HEAD~1..HEAD --name-only -- packages | awk '{c++} END {print c}')
  19. if [ -z "$count" ]; then
  20. echo "No changes in packages, skipping packages publishing"
  21. else
  22. echo "Changes detected in ${count} packages"
  23. echo "Releasing packages under ${PACKAGE_VERSION}-${GIT_SHA}"
  24. npx lerna version "${PACKAGE_VERSION}-${GIT_SHA}" --no-git-tag-version --no-push --force-publish -y
  25. echo $'\nGit status:'
  26. git status -s
  27. echo $'\nBuilding packages'
  28. yarn packages:build
  29. prapare_version_commit
  30. echo $'\nPublishing packages'
  31. yarn packages:publishNext
  32. fi