2020-08-20 15:46:23 +00:00
|
|
|
VERSION := $(shell git describe --tags --always --dirty="-dev" --match "[0-9][0-9][0-9][0-9].*.*")
|
2018-07-24 19:55:18 +00:00
|
|
|
DATE := $(shell date -u '+%Y-%m-%d-%H%M UTC')
|
|
|
|
VERSION_FLAGS := -ldflags='-X "main.Version=$(VERSION)" -X "main.BuildTime=$(DATE)"'
|
2020-07-07 15:44:07 +00:00
|
|
|
MSI_VERSION := $(shell git tag -l --sort=v:refname | grep "w" | tail -1 | cut -c2-)
|
|
|
|
#MSI_VERSION expects the format of the tag to be: (wX.X.X). Starts with the w character to not break cfsetup.
|
|
|
|
#e.g. w3.0.1 or w4.2.10. It trims off the w character when creating the MSI.
|
2018-07-24 19:55:18 +00:00
|
|
|
|
2018-07-25 21:05:46 +00:00
|
|
|
IMPORT_PATH := github.com/cloudflare/cloudflared
|
|
|
|
PACKAGE_DIR := $(CURDIR)/packaging
|
2020-07-02 18:23:54 +00:00
|
|
|
INSTALL_BINDIR := /usr/bin/
|
|
|
|
MAN_DIR := /usr/share/man/man1/
|
2018-07-25 21:05:46 +00:00
|
|
|
|
2018-07-26 20:45:18 +00:00
|
|
|
EQUINOX_FLAGS = --version="$(VERSION)" \
|
2020-05-29 01:06:27 +00:00
|
|
|
--platforms="$(EQUINOX_BUILD_PLATFORMS)" \
|
|
|
|
--app="$(EQUINOX_APP_ID)" \
|
|
|
|
--token="$(EQUINOX_TOKEN)" \
|
|
|
|
--channel="$(EQUINOX_CHANNEL)"
|
2018-07-26 20:45:18 +00:00
|
|
|
|
|
|
|
ifeq ($(EQUINOX_IS_DRAFT), true)
|
|
|
|
EQUINOX_FLAGS := --draft $(EQUINOX_FLAGS)
|
|
|
|
endif
|
|
|
|
|
2020-05-29 01:06:27 +00:00
|
|
|
LOCAL_ARCH ?= $(shell uname -m)
|
2020-06-30 19:46:05 +00:00
|
|
|
ifneq ($(GOARCH),)
|
|
|
|
TARGET_ARCH ?= $(GOARCH)
|
|
|
|
else ifeq ($(LOCAL_ARCH),x86_64)
|
2020-05-29 01:06:27 +00:00
|
|
|
TARGET_ARCH ?= amd64
|
2020-07-07 15:44:07 +00:00
|
|
|
else ifeq ($(LOCAL_ARCH),i686)
|
|
|
|
TARGET_ARCH ?= amd64
|
2020-05-29 01:06:27 +00:00
|
|
|
else ifeq ($(shell echo $(LOCAL_ARCH) | head -c 5),armv8)
|
|
|
|
TARGET_ARCH ?= arm64
|
|
|
|
else ifeq ($(LOCAL_ARCH),aarch64)
|
|
|
|
TARGET_ARCH ?= arm64
|
|
|
|
else ifeq ($(shell echo $(LOCAL_ARCH) | head -c 4),armv)
|
|
|
|
TARGET_ARCH ?= arm
|
|
|
|
else
|
|
|
|
$(error This system's architecture $(LOCAL_ARCH) isn't supported)
|
|
|
|
endif
|
|
|
|
|
|
|
|
LOCAL_OS ?= $(shell go env GOOS)
|
|
|
|
ifeq ($(LOCAL_OS),linux)
|
|
|
|
TARGET_OS ?= linux
|
|
|
|
else ifeq ($(LOCAL_OS),darwin)
|
|
|
|
TARGET_OS ?= darwin
|
2020-06-09 19:15:12 +00:00
|
|
|
else ifeq ($(LOCAL_OS),windows)
|
|
|
|
TARGET_OS ?= windows
|
2020-05-29 01:06:27 +00:00
|
|
|
else
|
|
|
|
$(error This system's OS $(LOCAL_OS) isn't supported)
|
2018-10-19 19:01:08 +00:00
|
|
|
endif
|
|
|
|
|
2020-06-23 21:23:40 +00:00
|
|
|
ifeq ($(TARGET_OS), windows)
|
|
|
|
EXECUTABLE_PATH=./cloudflared.exe
|
|
|
|
else
|
|
|
|
EXECUTABLE_PATH=./cloudflared
|
|
|
|
endif
|
|
|
|
|
2020-07-06 19:44:39 +00:00
|
|
|
ifeq ($(FLAVOR), centos-7)
|
|
|
|
TARGET_PUBLIC_REPO ?= el7
|
|
|
|
else
|
|
|
|
TARGET_PUBLIC_REPO ?= $(FLAVOR)
|
|
|
|
endif
|
|
|
|
|
2018-07-24 19:55:18 +00:00
|
|
|
.PHONY: all
|
|
|
|
all: cloudflared test
|
|
|
|
|
2018-10-18 22:26:21 +00:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
go clean
|
|
|
|
|
2018-07-24 19:55:18 +00:00
|
|
|
.PHONY: cloudflared
|
2019-03-29 23:05:11 +00:00
|
|
|
cloudflared: tunnel-deps
|
2020-05-29 01:06:27 +00:00
|
|
|
GOOS=$(TARGET_OS) GOARCH=$(TARGET_ARCH) go build -v -mod=vendor $(VERSION_FLAGS) $(IMPORT_PATH)/cmd/cloudflared
|
2018-07-24 19:55:18 +00:00
|
|
|
|
2019-04-29 21:25:34 +00:00
|
|
|
.PHONY: container
|
|
|
|
container:
|
2020-05-29 01:06:27 +00:00
|
|
|
docker build --build-arg=TARGET_ARCH=$(TARGET_ARCH) --build-arg=TARGET_OS=$(TARGET_OS) -t cloudflare/cloudflared-$(TARGET_OS)-$(TARGET_ARCH):"$(VERSION)" .
|
2019-04-29 21:25:34 +00:00
|
|
|
|
2018-07-24 19:55:18 +00:00
|
|
|
.PHONY: test
|
2019-03-29 23:05:11 +00:00
|
|
|
test: vet
|
2019-11-04 20:28:48 +00:00
|
|
|
go test -v -mod=vendor -race $(VERSION_FLAGS) ./...
|
2018-07-25 21:05:46 +00:00
|
|
|
|
2019-09-18 16:33:13 +00:00
|
|
|
.PHONY: test-ssh-server
|
|
|
|
test-ssh-server:
|
|
|
|
docker-compose -f ssh_server_tests/docker-compose.yml up
|
|
|
|
|
2020-06-30 15:43:54 +00:00
|
|
|
define publish_package
|
2020-06-26 18:47:11 +00:00
|
|
|
for HOST in $(CF_PKG_HOSTS); do \
|
|
|
|
ssh-keyscan -t rsa $$HOST >> ~/.ssh/known_hosts; \
|
2020-07-13 17:14:48 +00:00
|
|
|
scp -4 cloudflared*.$(1) cfsync@$$HOST:/state/cf-pkg/staging/$(2)/$(TARGET_PUBLIC_REPO)/cloudflared/; \
|
2020-06-26 18:47:11 +00:00
|
|
|
done
|
2020-06-30 15:43:54 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
.PHONY: publish-deb
|
|
|
|
publish-deb: cloudflared-deb
|
2020-07-13 17:14:48 +00:00
|
|
|
$(call publish_package,deb,apt)
|
2020-06-30 15:43:54 +00:00
|
|
|
|
|
|
|
.PHONY: publish-rpm
|
|
|
|
publish-rpm: cloudflared-rpm
|
2020-07-13 17:14:48 +00:00
|
|
|
$(call publish_package,rpm,yum)
|
2020-06-26 18:47:11 +00:00
|
|
|
|
2020-07-02 18:23:54 +00:00
|
|
|
define build_package
|
2018-07-25 21:05:46 +00:00
|
|
|
mkdir -p $(PACKAGE_DIR)
|
|
|
|
cp cloudflared $(PACKAGE_DIR)/cloudflared
|
2020-07-02 18:23:54 +00:00
|
|
|
cat cloudflared_man_template | sed -e 's/\$${VERSION}/$(VERSION)/; s/\$${DATE}/$(DATE)/' > $(PACKAGE_DIR)/cloudflared.1
|
|
|
|
fakeroot fpm -C $(PACKAGE_DIR) -s dir -t $(1) --$(1)-compression bzip2 \
|
2020-07-08 14:36:42 +00:00
|
|
|
--description 'Cloudflare Argo tunnel daemon' \
|
|
|
|
--vendor 'Cloudflare' \
|
|
|
|
--license 'Cloudflare Service Agreement' \
|
|
|
|
--url 'https://github.com/cloudflare/cloudflared' \
|
|
|
|
-m 'Cloudflare <support@cloudflare.com>' \
|
2020-07-02 18:23:54 +00:00
|
|
|
-a $(TARGET_ARCH) -v $(VERSION) -n cloudflared --after-install postinst.sh --after-remove postrm.sh \
|
|
|
|
cloudflared=$(INSTALL_BINDIR) cloudflared.1=$(MAN_DIR)
|
|
|
|
endef
|
|
|
|
|
|
|
|
.PHONY: cloudflared-deb
|
|
|
|
cloudflared-deb: cloudflared
|
|
|
|
$(call build_package,deb)
|
2018-07-26 20:45:18 +00:00
|
|
|
|
2020-06-30 15:43:54 +00:00
|
|
|
.PHONY: cloudflared-rpm
|
|
|
|
cloudflared-rpm: cloudflared
|
2020-07-02 18:23:54 +00:00
|
|
|
$(call build_package,rpm)
|
2020-06-30 15:43:54 +00:00
|
|
|
|
2018-08-16 00:11:30 +00:00
|
|
|
.PHONY: cloudflared-darwin-amd64.tgz
|
|
|
|
cloudflared-darwin-amd64.tgz: cloudflared
|
|
|
|
tar czf cloudflared-darwin-amd64.tgz cloudflared
|
|
|
|
rm cloudflared
|
|
|
|
|
|
|
|
.PHONY: homebrew-upload
|
|
|
|
homebrew-upload: cloudflared-darwin-amd64.tgz
|
|
|
|
aws s3 --endpoint-url $(S3_ENDPOINT) cp --acl public-read $$^ $(S3_URI)/cloudflared-$$(VERSION)-$1.tgz
|
|
|
|
aws s3 --endpoint-url $(S3_ENDPOINT) cp --acl public-read $(S3_URI)/cloudflared-$$(VERSION)-$1.tgz $(S3_URI)/cloudflared-stable-$1.tgz
|
2019-03-29 23:05:11 +00:00
|
|
|
|
|
|
|
.PHONY: homebrew-release
|
2018-08-16 00:11:30 +00:00
|
|
|
homebrew-release: homebrew-upload
|
|
|
|
./publish-homebrew-formula.sh cloudflared-darwin-amd64.tgz $(VERSION) homebrew-cloudflare
|
|
|
|
|
2018-07-26 20:45:18 +00:00
|
|
|
.PHONY: release
|
|
|
|
release: bin/equinox
|
|
|
|
bin/equinox release $(EQUINOX_FLAGS) -- $(VERSION_FLAGS) $(IMPORT_PATH)/cmd/cloudflared
|
|
|
|
|
2020-06-23 21:23:40 +00:00
|
|
|
.PHONY: github-release
|
|
|
|
github-release: cloudflared
|
|
|
|
python3 github_release.py --path $(EXECUTABLE_PATH) --release-version $(VERSION)
|
|
|
|
|
2020-07-29 17:50:25 +00:00
|
|
|
.PHONY: github-message
|
|
|
|
github-message:
|
|
|
|
python3 github_message.py --release-version $(VERSION)
|
|
|
|
|
2020-08-07 19:01:38 +00:00
|
|
|
.PHONY: github-mac-upload
|
|
|
|
github-mac-upload:
|
|
|
|
python3 github_release.py --path .artifacts/cloudflared-darwin-amd64.tgz --release-version $(VERSION) --name cloudflared-darwin-amd64.tgz
|
|
|
|
python3 github_release.py --path .artifacts/cloudflared-amd64.pkg --release-version $(VERSION) --name cloudflared-amd64.pkg
|
|
|
|
|
2018-07-26 20:45:18 +00:00
|
|
|
bin/equinox:
|
|
|
|
mkdir -p bin
|
|
|
|
curl -s https://bin.equinox.io/c/75JtLRTsJ3n/release-tool-beta-$(EQUINOX_PLATFORM).tgz | tar xz -C bin/
|
2018-10-08 19:20:28 +00:00
|
|
|
|
|
|
|
.PHONY: tunnel-deps
|
2019-03-29 23:05:11 +00:00
|
|
|
tunnel-deps: tunnelrpc/tunnelrpc.capnp.go
|
|
|
|
|
|
|
|
tunnelrpc/tunnelrpc.capnp.go: tunnelrpc/tunnelrpc.capnp
|
|
|
|
which capnp # https://capnproto.org/install.html
|
|
|
|
which capnpc-go # go get zombiezen.com/go/capnproto2/capnpc-go
|
2019-05-17 14:23:05 +00:00
|
|
|
capnp compile -ogo tunnelrpc/tunnelrpc.capnp
|
2019-03-29 23:05:11 +00:00
|
|
|
|
|
|
|
.PHONY: vet
|
|
|
|
vet:
|
2019-11-04 20:28:48 +00:00
|
|
|
go vet -mod=vendor ./...
|
2019-03-29 23:05:11 +00:00
|
|
|
which go-sumtype # go get github.com/BurntSushi/go-sumtype
|
2019-11-04 20:28:48 +00:00
|
|
|
go-sumtype $$(go list -mod=vendor ./...)
|
2020-07-07 15:44:07 +00:00
|
|
|
|
|
|
|
.PHONY: msi
|
|
|
|
msi: cloudflared
|
|
|
|
go-msi make --msi cloudflared.msi --version $(MSI_VERSION)
|