github.com/xhghs/rclone@v1.51.1-0.20200430155106-e186a28cced8/Makefile (about) 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 44 .PHONY: rclone test_all vars version 45 46 rclone: 47 go build -v --ldflags "-s -X github.com/rclone/rclone/fs.Version=$(TAG)" $(BUILDTAGS) 48 mkdir -p `go env GOPATH`/bin/ 49 cp -av rclone`go env GOEXE` `go env GOPATH`/bin/rclone`go env GOEXE`.new 50 mv -v `go env GOPATH`/bin/rclone`go env GOEXE`.new `go env GOPATH`/bin/rclone`go env GOEXE` 51 52 test_all: 53 go install --ldflags "-s -X github.com/rclone/rclone/fs.Version=$(TAG)" $(BUILDTAGS) github.com/rclone/rclone/fstest/test_all 54 55 vars: 56 @echo SHELL="'$(SHELL)'" 57 @echo BRANCH="'$(BRANCH)'" 58 @echo TAG="'$(TAG)'" 59 @echo VERSION="'$(VERSION)'" 60 @echo NEXT_VERSION="'$(NEXT_VERSION)'" 61 @echo GO_VERSION="'$(GO_VERSION)'" 62 @echo BETA_URL="'$(BETA_URL)'" 63 64 version: 65 @echo '$(TAG)' 66 67 # Full suite of integration tests 68 test: rclone test_all 69 -test_all 2>&1 | tee test_all.log 70 @echo "Written logs in test_all.log" 71 72 # Quick test 73 quicktest: 74 RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) $(GO_FILES) 75 76 racequicktest: 77 RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) -cpu=2 -race $(GO_FILES) 78 79 # Do source code quality checks 80 check: rclone 81 @echo "-- START CODE QUALITY REPORT -------------------------------" 82 @golangci-lint run $(LINTTAGS) ./... 83 @echo "-- END CODE QUALITY REPORT ---------------------------------" 84 85 # Get the build dependencies 86 build_dep: 87 go run bin/get-github-release.go -extract golangci-lint golangci/golangci-lint 'golangci-lint-.*\.tar\.gz' 88 89 # Get the release dependencies 90 release_dep: 91 go run bin/get-github-release.go -extract nfpm goreleaser/nfpm 'nfpm_.*_Linux_x86_64.tar.gz' 92 go run bin/get-github-release.go -extract github-release aktau/github-release 'linux-amd64-github-release.tar.bz2' 93 94 # Update dependencies 95 update: 96 GO111MODULE=on go get -u ./... 97 GO111MODULE=on go mod tidy 98 GO111MODULE=on go mod vendor 99 100 # Tidy the module dependencies 101 tidy: 102 GO111MODULE=on go mod tidy 103 GO111MODULE=on go mod vendor 104 105 doc: rclone.1 MANUAL.html MANUAL.txt rcdocs commanddocs 106 107 rclone.1: MANUAL.md 108 pandoc -s --from markdown --to man MANUAL.md -o rclone.1 109 110 MANUAL.md: bin/make_manual.py docs/content/*.md commanddocs backenddocs 111 ./bin/make_manual.py 112 113 MANUAL.html: MANUAL.md 114 pandoc -s --from markdown --to html MANUAL.md -o MANUAL.html 115 116 MANUAL.txt: MANUAL.md 117 pandoc -s --from markdown --to plain MANUAL.md -o MANUAL.txt 118 119 commanddocs: rclone 120 XDG_CACHE_HOME="" XDG_CONFIG_HOME="" HOME="\$$HOME" USER="\$$USER" rclone gendocs docs/content/ 121 122 backenddocs: rclone bin/make_backend_docs.py 123 XDG_CACHE_HOME="" XDG_CONFIG_HOME="" HOME="\$$HOME" USER="\$$USER" ./bin/make_backend_docs.py 124 125 rcdocs: rclone 126 bin/make_rc_docs.sh 127 128 install: rclone 129 install -d ${DESTDIR}/usr/bin 130 install -t ${DESTDIR}/usr/bin ${GOPATH}/bin/rclone 131 132 clean: 133 go clean ./... 134 find . -name \*~ | xargs -r rm -f 135 rm -rf build docs/public 136 rm -f rclone fs/operations/operations.test fs/sync/sync.test fs/test_all.log test.log 137 138 website: 139 cd docs && hugo 140 141 upload_website: website 142 rclone -v sync docs/public memstore:www-rclone-org 143 144 tarball: 145 git archive -9 --format=tar.gz --prefix=rclone-$(TAG)/ -o build/rclone-$(TAG).tar.gz $(TAG) 146 147 sign_upload: 148 cd build && md5sum rclone-v* | gpg --clearsign > MD5SUMS 149 cd build && sha1sum rclone-v* | gpg --clearsign > SHA1SUMS 150 cd build && sha256sum rclone-v* | gpg --clearsign > SHA256SUMS 151 152 check_sign: 153 cd build && gpg --verify MD5SUMS && gpg --decrypt MD5SUMS | md5sum -c 154 cd build && gpg --verify SHA1SUMS && gpg --decrypt SHA1SUMS | sha1sum -c 155 cd build && gpg --verify SHA256SUMS && gpg --decrypt SHA256SUMS | sha256sum -c 156 157 upload: 158 rclone -P copy build/ memstore:downloads-rclone-org/$(TAG) 159 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"' 160 161 upload_github: 162 ./bin/upload-github $(TAG) 163 164 cross: doc 165 go run bin/cross-compile.go -release current $(BUILDTAGS) $(TAG) 166 167 beta: 168 go run bin/cross-compile.go $(BUILDTAGS) $(TAG) 169 rclone -v copy build/ memstore:pub-rclone-org/$(TAG) 170 @echo Beta release ready at https://pub.rclone.org/$(TAG)/ 171 172 log_since_last_release: 173 git log $(LAST_TAG).. 174 175 compile_all: 176 go run bin/cross-compile.go -compile-only $(BUILDTAGS) $(TAG) 177 178 appveyor_upload: 179 rclone --config bin/travis.rclone.conf -v copy --exclude '*beta-latest*' build/ $(BETA_UPLOAD) 180 ifndef BRANCH_PATH 181 rclone --config bin/travis.rclone.conf -v copy --include '*beta-latest*' --include version.txt build/ $(BETA_UPLOAD_ROOT) 182 endif 183 @echo Beta release ready at $(BETA_URL) 184 185 circleci_upload: 186 sudo chown -R $$USER build 187 find build -type l -delete 188 gzip -r9v build 189 ./rclone --config bin/travis.rclone.conf -v copy build/ $(BETA_UPLOAD)/testbuilds 190 ifndef BRANCH_PATH 191 ./rclone --config bin/travis.rclone.conf -v copy build/ $(BETA_UPLOAD_ROOT)/test/testbuilds-latest 192 endif 193 @echo Beta release ready at $(BETA_URL)/testbuilds 194 195 travis_beta: 196 ifeq (linux,$(filter linux,$(subst Linux,linux,$(TRAVIS_OS_NAME) $(AGENT_OS)))) 197 go run bin/get-github-release.go -extract nfpm goreleaser/nfpm 'nfpm_.*\.tar.gz' 198 endif 199 git log $(LAST_TAG).. > /tmp/git-log.txt 200 go run bin/cross-compile.go -release beta-latest -git-log /tmp/git-log.txt $(BUILD_FLAGS) $(BUILDTAGS) $(TAG) 201 rclone --config bin/travis.rclone.conf -v copy --exclude '*beta-latest*' build/ $(BETA_UPLOAD) 202 ifndef BRANCH_PATH 203 rclone --config bin/travis.rclone.conf -v copy --include '*beta-latest*' --include version.txt build/ $(BETA_UPLOAD_ROOT)$(BETA_SUBDIR) 204 endif 205 @echo Beta release ready at $(BETA_URL) 206 207 # Fetch the binary builds from travis and appveyor 208 fetch_binaries: 209 rclone -P sync --exclude "/testbuilds/**" --delete-excluded $(BETA_UPLOAD) build/ 210 211 serve: website 212 cd docs && hugo server -v -w 213 214 tag: doc 215 @echo "Old tag is $(VERSION)" 216 @echo "New tag is $(NEXT_VERSION)" 217 echo -e "package fs\n\n// Version of rclone\nvar Version = \"$(NEXT_VERSION)\"\n" | gofmt > fs/version.go 218 echo -n "$(NEXT_VERSION)" > docs/layouts/partials/version.html 219 echo "$(NEXT_VERSION)" > VERSION 220 git tag -s -m "Version $(NEXT_VERSION)" $(NEXT_VERSION) 221 bin/make_changelog.py $(LAST_TAG) $(NEXT_VERSION) > docs/content/changelog.md.new 222 mv docs/content/changelog.md.new docs/content/changelog.md 223 @echo "Edit the new changelog in docs/content/changelog.md" 224 @echo "Then commit all the changes" 225 @echo git commit -m \"Version $(NEXT_VERSION)\" -a -v 226 @echo "And finally run make retag before make cross etc" 227 228 retag: 229 git tag -f -s -m "Version $(VERSION)" $(VERSION) 230 231 startdev: 232 echo -e "package fs\n\n// Version of rclone\nvar Version = \"$(VERSION)-DEV\"\n" | gofmt > fs/version.go 233 git commit -m "Start $(VERSION)-DEV development" fs/version.go 234 235 winzip: 236 zip -9 rclone-$(TAG).zip rclone.exe