release.sh 967 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. set -eu -o pipefail
  3. changelog=$(cat CHANGELOG.md)
  4. regex='
  5. ([0-9]+\.[0-9]+\.[0-9]+) \(([0-9]{4}-[0-9]{2}-[0-9]{2})\)
  6. -*
  7. ((.|
  8. )*)
  9. '
  10. if [[ ! $changelog =~ $regex ]]; then
  11. echo "Could not find date line in change log!"
  12. exit 1
  13. fi
  14. version="${BASH_REMATCH[1]}"
  15. date="${BASH_REMATCH[2]}"
  16. notes="$(echo "${BASH_REMATCH[3]}" | sed -n -E '/^[0-9]+\.[0-9]+\.[0-9]+/,$!p')"
  17. if [[ "$date" != $(date +"%Y-%m-%d") ]]; then
  18. echo "$date is not today!"
  19. exit 1
  20. fi
  21. tag="v$version"
  22. if [ -n "$(git status --porcelain)" ]; then
  23. echo ". is not clean." >&2
  24. exit 1
  25. fi
  26. php composer.phar self-update
  27. php composer.phar update
  28. ./vendor/bin/phpunit
  29. echo "Release notes for $tag:"
  30. echo "$notes"
  31. read -e -p "Commit changes and push to origin? " should_push
  32. if [ "$should_push" != "y" ]; then
  33. echo "Aborting"
  34. exit 1
  35. fi
  36. git push
  37. gh release create --target "$(git branch --show-current)" -t "$version" -n "$notes" "$tag"
  38. git push --tags