Makefile 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. SHELL = bash
  2. # Branch we are working on
  3. BRANCH := $(or $(APPVEYOR_REPO_BRANCH),$(TRAVIS_BRANCH),$(BUILD_SOURCEBRANCHNAME),$(lastword $(subst /, ,$(GITHUB_REF))),$(shell git rev-parse --abbrev-ref HEAD))
  4. # Tag of the current commit, if any. If this is not "" then we are building a release
  5. RELEASE_TAG := $(shell git tag -l --points-at HEAD)
  6. # Version of last release (may not be on this branch)
  7. VERSION := $(shell cat VERSION)
  8. # Last tag on this branch
  9. LAST_TAG := $(shell git describe --tags --abbrev=0)
  10. # If we are working on a release, override branch to master
  11. ifdef RELEASE_TAG
  12. BRANCH := master
  13. endif
  14. TAG_BRANCH := -$(BRANCH)
  15. BRANCH_PATH := branch/
  16. # If building HEAD or master then unset TAG_BRANCH and BRANCH_PATH
  17. ifeq ($(subst HEAD,,$(subst master,,$(BRANCH))),)
  18. TAG_BRANCH :=
  19. BRANCH_PATH :=
  20. endif
  21. # Make version suffix -DDD-gCCCCCCCC (D=commits since last relase, C=Commit) or blank
  22. VERSION_SUFFIX := $(shell git describe --abbrev=8 --tags | perl -lpe 's/^v\d+\.\d+\.\d+//; s/^-(\d+)/"-".sprintf("%03d",$$1)/e;')
  23. # TAG is current version + number of commits since last release + branch
  24. TAG := $(VERSION)$(VERSION_SUFFIX)$(TAG_BRANCH)
  25. NEXT_VERSION := $(shell echo $(VERSION) | perl -lpe 's/v//; $$_ += 0.01; $$_ = sprintf("v%.2f.0", $$_)')
  26. ifndef RELEASE_TAG
  27. TAG := $(TAG)-beta
  28. endif
  29. GO_VERSION := $(shell go version)
  30. GO_FILES := $(shell go list ./... | grep -v /vendor/ )
  31. ifdef BETA_SUBDIR
  32. BETA_SUBDIR := /$(BETA_SUBDIR)
  33. endif
  34. BETA_PATH := $(BRANCH_PATH)$(TAG)$(BETA_SUBDIR)
  35. BETA_URL := https://beta.rclone.org/$(BETA_PATH)/
  36. BETA_UPLOAD_ROOT := memstore:beta-rclone-org
  37. BETA_UPLOAD := $(BETA_UPLOAD_ROOT)/$(BETA_PATH)
  38. # Pass in GOTAGS=xyz on the make command line to set build tags
  39. ifdef GOTAGS
  40. BUILDTAGS=-tags "$(GOTAGS)"
  41. LINTTAGS=--build-tags "$(GOTAGS)"
  42. endif
  43. .PHONY: rclone test_all vars version
  44. rclone:
  45. go build -v --ldflags "-s -X github.com/rclone/rclone/fs.Version=$(TAG)" $(BUILDTAGS)
  46. mkdir -p `go env GOPATH`/bin/
  47. cp -av rclone`go env GOEXE` `go env GOPATH`/bin/rclone`go env GOEXE`.new
  48. mv -v `go env GOPATH`/bin/rclone`go env GOEXE`.new `go env GOPATH`/bin/rclone`go env GOEXE`
  49. test_all:
  50. go install --ldflags "-s -X github.com/rclone/rclone/fs.Version=$(TAG)" $(BUILDTAGS) github.com/rclone/rclone/fstest/test_all
  51. vars:
  52. @echo SHELL="'$(SHELL)'"
  53. @echo BRANCH="'$(BRANCH)'"
  54. @echo TAG="'$(TAG)'"
  55. @echo VERSION="'$(VERSION)'"
  56. @echo NEXT_VERSION="'$(NEXT_VERSION)'"
  57. @echo GO_VERSION="'$(GO_VERSION)'"
  58. @echo BETA_URL="'$(BETA_URL)'"
  59. version:
  60. @echo '$(TAG)'
  61. # Full suite of integration tests
  62. test: rclone test_all
  63. -test_all 2>&1 | tee test_all.log
  64. @echo "Written logs in test_all.log"
  65. # Quick test
  66. quicktest:
  67. RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) $(GO_FILES)
  68. racequicktest:
  69. RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) -cpu=2 -race $(GO_FILES)
  70. # Do source code quality checks
  71. check: rclone
  72. @echo "-- START CODE QUALITY REPORT -------------------------------"
  73. @golangci-lint run $(LINTTAGS) ./...
  74. @echo "-- END CODE QUALITY REPORT ---------------------------------"
  75. # Get the build dependencies
  76. build_dep:
  77. go run bin/get-github-release.go -extract golangci-lint golangci/golangci-lint 'golangci-lint-.*\.tar\.gz'
  78. # Get the release dependencies
  79. release_dep:
  80. go run bin/get-github-release.go -extract nfpm goreleaser/nfpm 'nfpm_.*_Linux_x86_64.tar.gz'
  81. go run bin/get-github-release.go -extract github-release aktau/github-release 'linux-amd64-github-release.tar.bz2'
  82. # Update dependencies
  83. update:
  84. GO111MODULE=on go get -u ./...
  85. GO111MODULE=on go mod tidy
  86. GO111MODULE=on go mod vendor
  87. # Tidy the module dependencies
  88. tidy:
  89. GO111MODULE=on go mod tidy
  90. GO111MODULE=on go mod vendor
  91. doc: rclone.1 MANUAL.html MANUAL.txt rcdocs commanddocs
  92. rclone.1: MANUAL.md
  93. pandoc -s --from markdown --to man MANUAL.md -o rclone.1
  94. MANUAL.md: bin/make_manual.py docs/content/*.md commanddocs backenddocs
  95. ./bin/make_manual.py
  96. MANUAL.html: MANUAL.md
  97. pandoc -s --from markdown --to html MANUAL.md -o MANUAL.html
  98. MANUAL.txt: MANUAL.md
  99. pandoc -s --from markdown --to plain MANUAL.md -o MANUAL.txt
  100. commanddocs: rclone
  101. XDG_CACHE_HOME="" XDG_CONFIG_HOME="" HOME="\$$HOME" USER="\$$USER" rclone gendocs docs/content/
  102. backenddocs: rclone bin/make_backend_docs.py
  103. XDG_CACHE_HOME="" XDG_CONFIG_HOME="" HOME="\$$HOME" USER="\$$USER" ./bin/make_backend_docs.py
  104. rcdocs: rclone
  105. bin/make_rc_docs.sh
  106. install: rclone
  107. install -d ${DESTDIR}/usr/bin
  108. install -t ${DESTDIR}/usr/bin ${GOPATH}/bin/rclone
  109. clean:
  110. go clean ./...
  111. find . -name \*~ | xargs -r rm -f
  112. rm -rf build docs/public
  113. rm -f rclone fs/operations/operations.test fs/sync/sync.test fs/test_all.log test.log
  114. website:
  115. cd docs && hugo
  116. upload_website: website
  117. rclone -v sync docs/public memstore:www-rclone-org
  118. tarball:
  119. git archive -9 --format=tar.gz --prefix=rclone-$(TAG)/ -o build/rclone-$(TAG).tar.gz $(TAG)
  120. sign_upload:
  121. cd build && md5sum rclone-v* | gpg --clearsign > MD5SUMS
  122. cd build && sha1sum rclone-v* | gpg --clearsign > SHA1SUMS
  123. cd build && sha256sum rclone-v* | gpg --clearsign > SHA256SUMS
  124. check_sign:
  125. cd build && gpg --verify MD5SUMS && gpg --decrypt MD5SUMS | md5sum -c
  126. cd build && gpg --verify SHA1SUMS && gpg --decrypt SHA1SUMS | sha1sum -c
  127. cd build && gpg --verify SHA256SUMS && gpg --decrypt SHA256SUMS | sha256sum -c
  128. upload:
  129. rclone -P copy build/ memstore:downloads-rclone-org/$(TAG)
  130. rclone lsf build --files-only --include '*.{zip,deb,rpm}' --include version.txt | xargs -i bash -c 'i={}; j="$$i"; [[ $$i =~ (.*)(-v[0-9\.]+-)(.*) ]] && j=$${BASH_REMATCH[1]}-current-$${BASH_REMATCH[3]}; rclone copyto -v "memstore:downloads-rclone-org/$(TAG)/$$i" "memstore:downloads-rclone-org/$$j"'
  131. upload_github:
  132. ./bin/upload-github $(TAG)
  133. cross: doc
  134. go run bin/cross-compile.go -release current $(BUILDTAGS) $(TAG)
  135. beta:
  136. go run bin/cross-compile.go $(BUILDTAGS) $(TAG)
  137. rclone -v copy build/ memstore:pub-rclone-org/$(TAG)
  138. @echo Beta release ready at https://pub.rclone.org/$(TAG)/
  139. log_since_last_release:
  140. git log $(LAST_TAG)..
  141. compile_all:
  142. go run bin/cross-compile.go -compile-only $(BUILDTAGS) $(TAG)
  143. appveyor_upload:
  144. rclone --config bin/travis.rclone.conf -v copy --exclude '*beta-latest*' build/ $(BETA_UPLOAD)
  145. ifndef BRANCH_PATH
  146. rclone --config bin/travis.rclone.conf -v copy --include '*beta-latest*' --include version.txt build/ $(BETA_UPLOAD_ROOT)
  147. endif
  148. @echo Beta release ready at $(BETA_URL)
  149. circleci_upload:
  150. sudo chown -R $$USER build
  151. find build -type l -delete
  152. gzip -r9v build
  153. ./rclone --config bin/travis.rclone.conf -v copy build/ $(BETA_UPLOAD)/testbuilds
  154. ifndef BRANCH_PATH
  155. ./rclone --config bin/travis.rclone.conf -v copy build/ $(BETA_UPLOAD_ROOT)/test/testbuilds-latest
  156. endif
  157. @echo Beta release ready at $(BETA_URL)/testbuilds
  158. travis_beta:
  159. ifeq (linux,$(filter linux,$(subst Linux,linux,$(TRAVIS_OS_NAME) $(AGENT_OS))))
  160. go run bin/get-github-release.go -extract nfpm goreleaser/nfpm 'nfpm_.*\.tar.gz'
  161. endif
  162. git log $(LAST_TAG).. > /tmp/git-log.txt
  163. go run bin/cross-compile.go -release beta-latest -git-log /tmp/git-log.txt $(BUILD_FLAGS) $(BUILDTAGS) $(TAG)
  164. rclone --config bin/travis.rclone.conf -v copy --exclude '*beta-latest*' build/ $(BETA_UPLOAD)
  165. ifndef BRANCH_PATH
  166. rclone --config bin/travis.rclone.conf -v copy --include '*beta-latest*' --include version.txt build/ $(BETA_UPLOAD_ROOT)$(BETA_SUBDIR)
  167. endif
  168. @echo Beta release ready at $(BETA_URL)
  169. # Fetch the binary builds from travis and appveyor
  170. fetch_binaries:
  171. rclone -P sync --exclude "/testbuilds/**" --delete-excluded $(BETA_UPLOAD) build/
  172. serve: website
  173. cd docs && hugo server -v -w
  174. tag: doc
  175. @echo "Old tag is $(VERSION)"
  176. @echo "New tag is $(NEXT_VERSION)"
  177. echo -e "package fs\n\n// Version of rclone\nvar Version = \"$(NEXT_VERSION)\"\n" | gofmt > fs/version.go
  178. echo -n "$(NEXT_VERSION)" > docs/layouts/partials/version.html
  179. echo "$(NEXT_VERSION)" > VERSION
  180. git tag -s -m "Version $(NEXT_VERSION)" $(NEXT_VERSION)
  181. bin/make_changelog.py $(LAST_TAG) $(NEXT_VERSION) > docs/content/changelog.md.new
  182. mv docs/content/changelog.md.new docs/content/changelog.md
  183. @echo "Edit the new changelog in docs/content/changelog.md"
  184. @echo "Then commit all the changes"
  185. @echo git commit -m \"Version $(NEXT_VERSION)\" -a -v
  186. @echo "And finally run make retag before make cross etc"
  187. retag:
  188. git tag -f -s -m "Version $(VERSION)" $(VERSION)
  189. startdev:
  190. echo -e "package fs\n\n// Version of rclone\nvar Version = \"$(VERSION)-DEV\"\n" | gofmt > fs/version.go
  191. git commit -m "Start $(VERSION)-DEV development" fs/version.go
  192. winzip:
  193. zip -9 rclone-$(TAG).zip rclone.exe