Makefile 3.8 KB

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