release.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 ! type "gh" > /dev/null; then
  14. echo "The \"gh\" command must be installed."
  15. exit 1
  16. fi
  17. if [[ $# -ne 1 ]]; then
  18. echo "Usage: ./release.sh version" >&2
  19. exit 1
  20. fi
  21. # Adapted from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
  22. 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
  23. echo "Invalid version number: $1" >&2
  24. exit 1
  25. fi
  26. git checkout main
  27. git pull
  28. cd caddy/
  29. go get "github.com/dunglas/frankenphp@v$1"
  30. cd -
  31. git commit -S -a -m "chore: prepare release $1" || echo "skip"
  32. git tag -s -m "Version $1" "v$1"
  33. git tag -s -m "Version $1" "caddy/v$1"
  34. git push --follow-tags
  35. tags=$(git tag --list --sort=-version:refname 'v*')
  36. previous_tag=$(awk 'NR==2 {print;exit}' <<< "${tags}")
  37. gh release create --draft --generate-notes --latest --notes-start-tag "${previous_tag}" --verify-tag "v$1"
  38. if [[ "$(uname -s)" = "Darwin" ]]; then
  39. rm -Rf dist/*
  40. FRANKENPHP_VERSION=$1 RELEASE=1 ./build-static.sh
  41. fi