Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. VERSION=
  2. REMOTE="origin"
  3. # Use the version number to figure out if the release
  4. # is a pre-release
  5. PRERELEASE=$(shell echo $(VERSION) | grep -E 'dev|rc|alpha|beta' --quiet && echo 'true' || echo 'false')
  6. # Github settings
  7. UPLOAD_HOST=https://uploads.github.com
  8. API_HOST=https://api.github.com
  9. GITHUB_USER=
  10. ALL: help
  11. .PHONY: help install test need-version bump-version tag-version
  12. help:
  13. @echo "CakePHP Makefile"
  14. @echo "================"
  15. @echo ""
  16. @echo "release"
  17. @echo " Create a new release of CakePHP. Requires the VERSION and GITHUB_USER parameter."
  18. @echo " Packages up a new app skeleton tarball and uploads it to github."
  19. @echo ""
  20. @echo "package"
  21. @echo " Build the app package with all its dependencies."
  22. @echo ""
  23. @echo "publish"
  24. @echo " Publish the dist/cakephp-VERSION.zip to github."
  25. @echo ""
  26. @echo "test"
  27. @echo " Run the tests for CakePHP."
  28. @echo ""
  29. @echo "All other tasks are not intended to be run directly."
  30. # Download composer
  31. composer.phar:
  32. curl -sS https://getcomposer.org/installer | php
  33. # Install dependencies
  34. install: composer.phar
  35. php composer.phar install
  36. test: install
  37. vendor/bin/phpunit
  38. guard-%:
  39. @if [ "$($*)" = '' ]; then \
  40. echo "Missing required $* variable."; \
  41. exit 1; \
  42. fi;
  43. # Update VERSION.txt to new version.
  44. bump-version: guard-VERSION
  45. @echo "Update VERSION.txt to $(VERSION)"
  46. # Work around bash being bad.
  47. mv VERSION.txt VERSION.old
  48. cat VERSION.old | sed s'/^[0-9]\.[0-9]\.[0-9].*/$(VERSION)/' > VERSION.txt
  49. rm VERSION.old
  50. git add VERSION.txt
  51. git commit -m "Update version number to $(VERSION)"
  52. # Tag a release
  53. tag-release: guard-VERSION bump-version
  54. @echo "Tagging $(VERSION)"
  55. git tag -s $(VERSION) -m "CakePHP $(VERSION)"
  56. git push $(REMOTE)
  57. git push $(REMOTE) --tags
  58. # Tasks for tagging the app skeletong and
  59. # creating a zipball of a fully built app skeleton.
  60. .PHONY: clean tag-app build-app package
  61. clean:
  62. rm -rf build
  63. rm -rf dist
  64. build/app:
  65. @if [ ! -d build ]; \
  66. then \
  67. mkdir build; \
  68. fi;
  69. git clone git@github.com:cakephp/app.git build/app
  70. tag-app: guard-VERSION build/app
  71. @echo "Tagging new version of application skeleton"
  72. cd build/app && git tag -s $(VERSION) -m "CakePHP App $(VERSION)"
  73. cd build/app && git push $(REMOTE)
  74. cd build/app && git push $(REMOTE) --tags
  75. # Easier to type alias for zip balls
  76. package: tag-app dist/cakephp-$(VERSION).zip
  77. dist/cakephp-$(VERSION).zip: composer.phar
  78. @if [ ! -d dist ]; \
  79. then \
  80. mkdir dist; \
  81. fi;
  82. @echo "Installing app dependencies with composer"
  83. cd build/app && php ../../composer.phar install
  84. # Make a zipball of all the files that are not in .git dirs
  85. # Including .git will make zip balls huge, and the zipball is
  86. # intended for quick start non-git, non-cli users
  87. @echo "Building zipball for $(VERSION)"
  88. find build/app -not -path '*.git*' | zip dist/cakephp-$(VERSION).zip -@
  89. # Tasks to publish zipballs to github.
  90. .PHONY: publish release
  91. publish: guard-VERSION guard-GITHUB_USER dist/cakephp-$(VERSION).zip
  92. @echo "Creating draft release for $(VERSION). prerelease=$(PRERELEASE)"
  93. curl -u $(GITHUB_USER) -p -XPOST $(API_HOST)/repos/cakephp/cakephp/releases -d '{ \
  94. "tag_name": "$(VERSION)", \
  95. "target_commitish": "3.0", \
  96. "name": "CakePHP $(VERSION) released", \
  97. "draft": true, \
  98. "prerelease": $(PRERELEASE) \
  99. }' > release.json
  100. # Extract id out of response json.
  101. php -r '$$f = file_get_contents("./release.json"); \
  102. $$d = json_decode($$f, true); \
  103. file_put_contents("./id.txt", $$d["id"]);'
  104. @echo "Uploading zip file to github."
  105. curl -u $(GITHUB_USER) -p -XPOST \
  106. $(UPLOAD_HOST)/repos/cakephp/cakephp/releases/`cat ./id.txt`/assets?name=cakephp-$(VERSION).zip \
  107. -H 'Content-Type: application/zip' \
  108. -d '@dist/cakephp-$(VERSION).zip'
  109. # Cleanup files.
  110. rm release.json
  111. rm id.txt
  112. # Top level alias for doing a release.
  113. release: guard-VERSION guard-GITHUB_USER package publish