github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/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 rm -rf docs/public 140 cd docs && hugo 141 @if grep -R "raw HTML omitted" docs/public ; then echo "ERROR: found unescaped HTML - fix the markdown source" ; fi 142 143 upload_website: website 144 rclone -v sync docs/public memstore:www-rclone-org 145 146 upload_test_website: website 147 rclone -P sync docs/public test-rclone-org: 148 149 validate_website: website 150 find docs/public -type f -name "*.html" | xargs tidy --mute-id yes -errors --gnu-emacs yes --drop-empty-elements no --warn-proprietary-attributes no --mute MISMATCHED_ATTRIBUTE_WARN 151 152 tarball: 153 git archive -9 --format=tar.gz --prefix=rclone-$(TAG)/ -o build/rclone-$(TAG).tar.gz $(TAG) 154 155 sign_upload: 156 cd build && md5sum rclone-v* | gpg --clearsign > MD5SUMS 157 cd build && sha1sum rclone-v* | gpg --clearsign > SHA1SUMS 158 cd build && sha256sum rclone-v* | gpg --clearsign > SHA256SUMS 159 160 check_sign: 161 cd build && gpg --verify MD5SUMS && gpg --decrypt MD5SUMS | md5sum -c 162 cd build && gpg --verify SHA1SUMS && gpg --decrypt SHA1SUMS | sha1sum -c 163 cd build && gpg --verify SHA256SUMS && gpg --decrypt SHA256SUMS | sha256sum -c 164 165 upload: 166 rclone -P copy build/ memstore:downloads-rclone-org/$(TAG) 167 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"' 168 169 upload_github: 170 ./bin/upload-github $(TAG) 171 172 cross: doc 173 go run bin/cross-compile.go -release current $(BUILDTAGS) $(TAG) 174 175 beta: 176 go run bin/cross-compile.go $(BUILDTAGS) $(TAG) 177 rclone -v copy build/ memstore:pub-rclone-org/$(TAG) 178 @echo Beta release ready at https://pub.rclone.org/$(TAG)/ 179 180 log_since_last_release: 181 git log $(LAST_TAG).. 182 183 compile_all: 184 go run bin/cross-compile.go -compile-only $(BUILDTAGS) $(TAG) 185 186 appveyor_upload: 187 rclone --config bin/travis.rclone.conf -v copy --exclude '*beta-latest*' build/ $(BETA_UPLOAD) 188 ifndef BRANCH_PATH 189 rclone --config bin/travis.rclone.conf -v copy --include '*beta-latest*' --include version.txt build/ $(BETA_UPLOAD_ROOT) 190 endif 191 @echo Beta release ready at $(BETA_URL) 192 193 circleci_upload: 194 sudo chown -R $$USER build 195 find build -type l -delete 196 gzip -r9v build 197 ./rclone --config bin/travis.rclone.conf -v copy build/ $(BETA_UPLOAD)/testbuilds 198 ifndef BRANCH_PATH 199 ./rclone --config bin/travis.rclone.conf -v copy build/ $(BETA_UPLOAD_ROOT)/test/testbuilds-latest 200 endif 201 @echo Beta release ready at $(BETA_URL)/testbuilds 202 203 travis_beta: 204 ifeq (linux,$(filter linux,$(subst Linux,linux,$(TRAVIS_OS_NAME) $(AGENT_OS)))) 205 go run bin/get-github-release.go -extract nfpm goreleaser/nfpm 'nfpm_.*\.tar.gz' 206 endif 207 git log $(LAST_TAG).. > /tmp/git-log.txt 208 go run bin/cross-compile.go -release beta-latest -git-log /tmp/git-log.txt $(BUILD_FLAGS) $(BUILDTAGS) $(TAG) 209 rclone --config bin/travis.rclone.conf -v copy --exclude '*beta-latest*' build/ $(BETA_UPLOAD) 210 ifndef BRANCH_PATH 211 rclone --config bin/travis.rclone.conf -v copy --include '*beta-latest*' --include version.txt build/ $(BETA_UPLOAD_ROOT)$(BETA_SUBDIR) 212 endif 213 @echo Beta release ready at $(BETA_URL) 214 215 # Fetch the binary builds from travis and appveyor 216 fetch_binaries: 217 rclone -P sync --exclude "/testbuilds/**" --delete-excluded $(BETA_UPLOAD) build/ 218 219 serve: website 220 cd docs && hugo server -v -w --disableFastRender 221 222 tag: doc 223 @echo "Old tag is $(VERSION)" 224 @echo "New tag is $(NEXT_VERSION)" 225 echo -e "package fs\n\n// Version of rclone\nvar Version = \"$(NEXT_VERSION)\"\n" | gofmt > fs/version.go 226 echo -n "$(NEXT_VERSION)" > docs/layouts/partials/version.html 227 echo "$(NEXT_VERSION)" > VERSION 228 git tag -s -m "Version $(NEXT_VERSION)" $(NEXT_VERSION) 229 bin/make_changelog.py $(LAST_TAG) $(NEXT_VERSION) > docs/content/changelog.md.new 230 mv docs/content/changelog.md.new docs/content/changelog.md 231 @echo "Edit the new changelog in docs/content/changelog.md" 232 @echo "Then commit all the changes" 233 @echo git commit -m \"Version $(NEXT_VERSION)\" -a -v 234 @echo "And finally run make retag before make cross etc" 235 236 retag: 237 git tag -f -s -m "Version $(VERSION)" $(VERSION) 238 239 startdev: 240 echo -e "package fs\n\n// Version of rclone\nvar Version = \"$(VERSION)-DEV\"\n" | gofmt > fs/version.go 241 git commit -m "Start $(VERSION)-DEV development" fs/version.go 242 243 winzip: 244 zip -9 rclone-$(TAG).zip rclone.exe