package 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env bash
  2. set -e
  3. cd "${BASH_SOURCE%/*}/.."
  4. USAGE="usage: bin/package [-v PACKAGE_VERSION]"
  5. while getopts ":v:h" opt; do
  6. case $opt in
  7. v)
  8. PKG_VERSION=$OPTARG
  9. ;;
  10. h)
  11. echo $USAGE >&2
  12. exit
  13. ;;
  14. \?)
  15. echo "Invalid option: -$OPTARG" >&2
  16. echo $USAGE >&2
  17. exit 1
  18. ;;
  19. :)
  20. echo "Option -$OPTARG requires an argument" >&2
  21. echo $USAGE >&2
  22. exit 1
  23. ;;
  24. esac
  25. done
  26. if [ -z "$PKG_VERSION" ]; then
  27. PKG_VERSION=$(git describe --tag --exact-match)
  28. fi
  29. if [[ $(php --version) = PHP\ 5.3* ]]; then
  30. PKG_VERSION=${PKG_VERSION}-php53
  31. fi
  32. echo "Packaging $PKG_VERSION"
  33. mkdir -p dist || exit 1
  34. ./bin/build || exit 1
  35. chmod +x *.phar
  36. echo "Creating tarballs"
  37. # Support BSD tar because OS X :(
  38. if [[ $(tar --version) = bsdtar* ]]; then
  39. tar -s "/.*/psysh/" -czf dist/psysh-${PKG_VERSION}.tar.gz psysh.phar
  40. tar -s "/.*/psysh/" -czf dist/psysh-${PKG_VERSION}-compat.tar.gz psysh-compat.phar
  41. else
  42. tar --transform "s/.*/psysh/" -czf dist/psysh-${PKG_VERSION}.tar.gz psysh.phar
  43. tar --transform "s/.*/psysh/" -czf dist/psysh-${PKG_VERSION}-compat.tar.gz psysh-compat.phar
  44. fi