Makefile 4.1 KB

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