github.com/divyam234/rclone@v1.64.1/Makefile (about) 1 SHELL = bash 2 # Branch we are working on 3 BRANCH := $(or $(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 # Next version 11 NEXT_VERSION := $(shell echo $(VERSION) | awk -F. -v OFS=. '{print $$1,$$2+1,0}') 12 NEXT_PATCH_VERSION := $(shell echo $(VERSION) | awk -F. -v OFS=. '{print $$1,$$2,$$3+1}') 13 # If we are working on a release, override branch to master 14 ifdef RELEASE_TAG 15 BRANCH := master 16 LAST_TAG := $(shell git describe --abbrev=0 --tags $(VERSION)^) 17 endif 18 TAG_BRANCH := .$(BRANCH) 19 BRANCH_PATH := branch/$(BRANCH)/ 20 # If building HEAD or master then unset TAG_BRANCH and BRANCH_PATH 21 ifeq ($(subst HEAD,,$(subst master,,$(BRANCH))),) 22 TAG_BRANCH := 23 BRANCH_PATH := 24 endif 25 # Make version suffix -beta.NNNN.CCCCCCCC (N=Commit number, C=Commit) 26 VERSION_SUFFIX := -beta.$(shell git rev-list --count HEAD).$(shell git show --no-patch --no-notes --pretty='%h' HEAD) 27 # TAG is current version + commit number + commit + branch 28 TAG := $(VERSION)$(VERSION_SUFFIX)$(TAG_BRANCH) 29 ifdef RELEASE_TAG 30 TAG := $(RELEASE_TAG) 31 endif 32 GO_VERSION := $(shell go version) 33 ifdef BETA_SUBDIR 34 BETA_SUBDIR := /$(BETA_SUBDIR) 35 endif 36 BETA_PATH := $(BRANCH_PATH)$(TAG)$(BETA_SUBDIR) 37 BETA_URL := https://beta.rclone.org/$(BETA_PATH)/ 38 BETA_UPLOAD_ROOT := memstore:beta-rclone-org 39 BETA_UPLOAD := $(BETA_UPLOAD_ROOT)/$(BETA_PATH) 40 # Pass in GOTAGS=xyz on the make command line to set build tags 41 ifdef GOTAGS 42 BUILDTAGS=-tags "$(GOTAGS)" 43 LINTTAGS=--build-tags "$(GOTAGS)" 44 endif 45 46 .PHONY: rclone test_all vars version 47 48 rclone: 49 go build -v --ldflags "-s -X github.com/divyam234/rclone/fs.Version=$(TAG)" $(BUILDTAGS) $(BUILD_ARGS) 50 mkdir -p `go env GOPATH`/bin/ 51 cp -av rclone`go env GOEXE` `go env GOPATH`/bin/rclone`go env GOEXE`.new 52 mv -v `go env GOPATH`/bin/rclone`go env GOEXE`.new `go env GOPATH`/bin/rclone`go env GOEXE` 53 54 test_all: 55 go install --ldflags "-s -X github.com/divyam234/rclone/fs.Version=$(TAG)" $(BUILDTAGS) $(BUILD_ARGS) github.com/divyam234/rclone/fstest/test_all 56 57 vars: 58 @echo SHELL="'$(SHELL)'" 59 @echo BRANCH="'$(BRANCH)'" 60 @echo TAG="'$(TAG)'" 61 @echo VERSION="'$(VERSION)'" 62 @echo GO_VERSION="'$(GO_VERSION)'" 63 @echo BETA_URL="'$(BETA_URL)'" 64 65 btest: 66 @echo "[$(TAG)]($(BETA_URL)) on branch [$(BRANCH)](https://github.com/divyam234/rclone/tree/$(BRANCH)) (uploaded in 15-30 mins)" | xclip -r -sel clip 67 @echo "Copied markdown of beta release to clip board" 68 69 version: 70 @echo '$(TAG)' 71 72 # Full suite of integration tests 73 test: rclone test_all 74 -test_all 2>&1 | tee test_all.log 75 @echo "Written logs in test_all.log" 76 77 # Quick test 78 quicktest: 79 RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) ./... 80 81 racequicktest: 82 RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) -cpu=2 -race ./... 83 84 compiletest: 85 RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) -run XXX ./... 86 87 # Do source code quality checks 88 check: rclone 89 @echo "-- START CODE QUALITY REPORT -------------------------------" 90 @golangci-lint run $(LINTTAGS) ./... 91 @echo "-- END CODE QUALITY REPORT ---------------------------------" 92 93 # Get the build dependencies 94 build_dep: 95 go run bin/get-github-release.go -extract golangci-lint golangci/golangci-lint 'golangci-lint-.*\.tar\.gz' 96 97 # Get the release dependencies we only install on linux 98 release_dep_linux: 99 go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest 100 101 # Get the release dependencies we only install on Windows 102 release_dep_windows: 103 GOOS="" GOARCH="" go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@latest 104 105 # Update dependencies 106 showupdates: 107 @echo "*** Direct dependencies that could be updated ***" 108 @GO111MODULE=on go list -u -f '{{if (and (not (or .Main .Indirect)) .Update)}}{{.Path}}: {{.Version}} -> {{.Update.Version}}{{end}}' -m all 2> /dev/null 109 110 # Update direct dependencies only 111 updatedirect: 112 GO111MODULE=on go get -d $$(go list -m -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' all) 113 GO111MODULE=on go mod tidy 114 115 # Update direct and indirect dependencies and test dependencies 116 update: 117 GO111MODULE=on go get -d -u -t ./... 118 GO111MODULE=on go mod tidy 119 120 # Tidy the module dependencies 121 tidy: 122 GO111MODULE=on go mod tidy 123 124 doc: rclone.1 MANUAL.html MANUAL.txt rcdocs commanddocs 125 126 rclone.1: MANUAL.md 127 pandoc -s --from markdown-smart --to man MANUAL.md -o rclone.1 128 129 MANUAL.md: bin/make_manual.py docs/content/*.md commanddocs backenddocs rcdocs 130 ./bin/make_manual.py 131 132 MANUAL.html: MANUAL.md 133 pandoc -s --from markdown-smart --to html MANUAL.md -o MANUAL.html 134 135 MANUAL.txt: MANUAL.md 136 pandoc -s --from markdown-smart --to plain MANUAL.md -o MANUAL.txt 137 138 commanddocs: rclone 139 XDG_CACHE_HOME="" XDG_CONFIG_HOME="" HOME="\$$HOME" USER="\$$USER" rclone gendocs docs/content/ 140 141 backenddocs: rclone bin/make_backend_docs.py 142 XDG_CACHE_HOME="" XDG_CONFIG_HOME="" HOME="\$$HOME" USER="\$$USER" ./bin/make_backend_docs.py 143 144 rcdocs: rclone 145 bin/make_rc_docs.sh 146 147 install: rclone 148 install -d ${DESTDIR}/usr/bin 149 install -t ${DESTDIR}/usr/bin ${GOPATH}/bin/rclone 150 151 clean: 152 go clean ./... 153 find . -name \*~ | xargs -r rm -f 154 rm -rf build docs/public 155 rm -f rclone fs/operations/operations.test fs/sync/sync.test fs/test_all.log test.log 156 157 website: 158 rm -rf docs/public 159 cd docs && hugo 160 @if grep -R "raw HTML omitted" docs/public ; then echo "ERROR: found unescaped HTML - fix the markdown source" ; fi 161 162 upload_website: website 163 rclone -v sync docs/public memstore:www-rclone-org 164 165 upload_test_website: website 166 rclone -P sync docs/public test-rclone-org: 167 168 validate_website: website 169 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 170 171 tarball: 172 git archive -9 --format=tar.gz --prefix=rclone-$(TAG)/ -o build/rclone-$(TAG).tar.gz $(TAG) 173 174 vendorball: 175 go mod vendor 176 tar -zcf build/rclone-$(TAG)-vendor.tar.gz vendor 177 rm -rf vendor 178 179 sign_upload: 180 cd build && md5sum rclone-v* | gpg --clearsign > MD5SUMS 181 cd build && sha1sum rclone-v* | gpg --clearsign > SHA1SUMS 182 cd build && sha256sum rclone-v* | gpg --clearsign > SHA256SUMS 183 184 check_sign: 185 cd build && gpg --verify MD5SUMS && gpg --decrypt MD5SUMS | md5sum -c 186 cd build && gpg --verify SHA1SUMS && gpg --decrypt SHA1SUMS | sha1sum -c 187 cd build && gpg --verify SHA256SUMS && gpg --decrypt SHA256SUMS | sha256sum -c 188 189 upload: 190 rclone -P copy build/ memstore:downloads-rclone-org/$(TAG) 191 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"' 192 193 upload_github: 194 ./bin/upload-github $(TAG) 195 196 cross: doc 197 go run bin/cross-compile.go -release current $(BUILD_FLAGS) $(BUILDTAGS) $(BUILD_ARGS) $(TAG) 198 199 beta: 200 go run bin/cross-compile.go $(BUILD_FLAGS) $(BUILDTAGS) $(BUILD_ARGS) $(TAG) 201 rclone -v copy build/ memstore:pub-rclone-org/$(TAG) 202 @echo Beta release ready at https://pub.rclone.org/$(TAG)/ 203 204 log_since_last_release: 205 git log $(LAST_TAG).. 206 207 compile_all: 208 go run bin/cross-compile.go -compile-only $(BUILD_FLAGS) $(BUILDTAGS) $(BUILD_ARGS) $(TAG) 209 210 ci_upload: 211 sudo chown -R $$USER build 212 find build -type l -delete 213 gzip -r9v build 214 ./rclone --config bin/travis.rclone.conf -v copy build/ $(BETA_UPLOAD)/testbuilds 215 ifeq ($(or $(BRANCH_PATH),$(RELEASE_TAG)),) 216 ./rclone --config bin/travis.rclone.conf -v copy build/ $(BETA_UPLOAD_ROOT)/test/testbuilds-latest 217 endif 218 @echo Beta release ready at $(BETA_URL)/testbuilds 219 220 ci_beta: 221 git log $(LAST_TAG).. > /tmp/git-log.txt 222 go run bin/cross-compile.go -release beta-latest -git-log /tmp/git-log.txt $(BUILD_FLAGS) $(BUILDTAGS) $(BUILD_ARGS) $(TAG) 223 rclone --config bin/travis.rclone.conf -v copy --exclude '*beta-latest*' build/ $(BETA_UPLOAD) 224 ifeq ($(or $(BRANCH_PATH),$(RELEASE_TAG)),) 225 rclone --config bin/travis.rclone.conf -v copy --include '*beta-latest*' --include version.txt build/ $(BETA_UPLOAD_ROOT)$(BETA_SUBDIR) 226 endif 227 @echo Beta release ready at $(BETA_URL) 228 229 # Fetch the binary builds from GitHub actions 230 fetch_binaries: 231 rclone -P sync --exclude "/testbuilds/**" --delete-excluded $(BETA_UPLOAD) build/ 232 233 serve: website 234 cd docs && hugo server -v -w --disableFastRender 235 236 tag: retag doc 237 bin/make_changelog.py $(LAST_TAG) $(VERSION) > docs/content/changelog.md.new 238 mv docs/content/changelog.md.new docs/content/changelog.md 239 @echo "Edit the new changelog in docs/content/changelog.md" 240 @echo "Then commit all the changes" 241 @echo git commit -m \"Version $(VERSION)\" -a -v 242 @echo "And finally run make retag before make cross, etc." 243 244 retag: 245 @echo "Version is $(VERSION)" 246 git tag -f -s -m "Version $(VERSION)" $(VERSION) 247 248 startdev: 249 @echo "Version is $(VERSION)" 250 @echo "Next version is $(NEXT_VERSION)" 251 echo -e "package fs\n\n// VersionTag of rclone\nvar VersionTag = \"$(NEXT_VERSION)\"\n" | gofmt > fs/versiontag.go 252 echo -n "$(NEXT_VERSION)" > docs/layouts/partials/version.html 253 echo "$(NEXT_VERSION)" > VERSION 254 git commit -m "Start $(NEXT_VERSION)-DEV development" fs/versiontag.go VERSION docs/layouts/partials/version.html 255 256 startstable: 257 @echo "Version is $(VERSION)" 258 @echo "Next stable version is $(NEXT_PATCH_VERSION)" 259 echo -e "package fs\n\n// VersionTag of rclone\nvar VersionTag = \"$(NEXT_PATCH_VERSION)\"\n" | gofmt > fs/versiontag.go 260 echo -n "$(NEXT_PATCH_VERSION)" > docs/layouts/partials/version.html 261 echo "$(NEXT_PATCH_VERSION)" > VERSION 262 git commit -m "Start $(NEXT_PATCH_VERSION)-DEV development" fs/versiontag.go VERSION docs/layouts/partials/version.html 263 264 winzip: 265 zip -9 rclone-$(TAG).zip rclone.exe 266 267 # docker volume plugin 268 PLUGIN_USER ?= rclone 269 PLUGIN_TAG ?= latest 270 PLUGIN_BASE_TAG ?= latest 271 PLUGIN_ARCH ?= amd64 272 PLUGIN_IMAGE := $(PLUGIN_USER)/docker-volume-rclone:$(PLUGIN_TAG) 273 PLUGIN_BASE := $(PLUGIN_USER)/rclone:$(PLUGIN_BASE_TAG) 274 PLUGIN_BUILD_DIR := ./build/docker-plugin 275 PLUGIN_CONTRIB_DIR := ./contrib/docker-plugin/managed 276 277 docker-plugin-create: 278 docker buildx inspect |grep -q /${PLUGIN_ARCH} || \ 279 docker run --rm --privileged tonistiigi/binfmt --install all 280 rm -rf ${PLUGIN_BUILD_DIR} 281 docker buildx build \ 282 --no-cache --pull \ 283 --build-arg BASE_IMAGE=${PLUGIN_BASE} \ 284 --platform linux/${PLUGIN_ARCH} \ 285 --output ${PLUGIN_BUILD_DIR}/rootfs \ 286 ${PLUGIN_CONTRIB_DIR} 287 cp ${PLUGIN_CONTRIB_DIR}/config.json ${PLUGIN_BUILD_DIR} 288 docker plugin rm --force ${PLUGIN_IMAGE} 2>/dev/null || true 289 docker plugin create ${PLUGIN_IMAGE} ${PLUGIN_BUILD_DIR} 290 291 docker-plugin-push: 292 docker plugin push ${PLUGIN_IMAGE} 293 docker plugin rm ${PLUGIN_IMAGE} 294 295 docker-plugin: docker-plugin-create docker-plugin-push