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