release.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env bash
  2. # Creates the tags for the library and the Caddy module.
  3. set -o nounset
  4. set -o errexit
  5. trap 'echo "Aborting due to errexit on line $LINENO. Exit code: $?" >&2' ERR
  6. set -o errtrace
  7. set -o pipefail
  8. set -o xtrace
  9. if ! type "git" > /dev/null; then
  10. echo "The \"git\" command must be installed."
  11. exit 1
  12. fi
  13. if [ $# -ne 1 ]; then
  14. echo "Usage: ./release.sh version" >&2
  15. exit 1
  16. fi
  17. # Adapted from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
  18. if [[ ! $1 =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
  19. echo "Invalid version number: $1" >&2
  20. exit 1
  21. fi
  22. git checkout main
  23. git pull
  24. cd caddy/
  25. go get "github.com/dunglas/frankenphp@v$1"
  26. cd -
  27. git commit -S -a -m "chore: prepare release $1" || echo "skip"
  28. git tag -s -m "Version $1" "v$1"
  29. git tag -s -m "Version $1" "caddy/v$1"
  30. git push --follow-tags
  31. if [ "$(uname -s)" = "Darwin" ]; then
  32. rm -Rf dist/*
  33. FRANKENPHP_VERSION=$1 RELEASE=1 ./build-static.sh
  34. fi