mirror of
https://github.com/appleboy/drone-scp.git
synced 2026-06-04 10:15:05 +08:00
12827c56e5
- Remove redundant `DIST` variable declaration - Update `GOFMT` command to include `-s` and `-w` flags - Remove `SHASUM` variable declaration - Remove `XGO_PACKAGE` and `XGO_VERSION` variable declarations - Remove `GXZ_PAGAGE` variable declaration - Remove architecture-specific variables (`LINUX_ARCHS`, `DARWIN_ARCHS`, `WINDOWS_ARCHS`) - Remove `.PHONY` targets and associated rules for `deps-backend`, `release`, `release-windows`, `release-linux`, `release-darwin`, `release-copy`, `release-check`, and `release-compress` - Simplify the `Makefile` by removing complex release-related commands and dependencies Signed-off-by: appleboy <appleboy.tw@gmail.com>
113 lines
3.3 KiB
Makefile
113 lines
3.3 KiB
Makefile
EXECUTABLE := drone-scp
|
|
GOFMT ?= gofumpt -l -s -w
|
|
GO ?= go
|
|
GOFILES := $(shell find . -name "*.go" -type f)
|
|
HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
|
|
|
|
ifneq ($(shell uname), Darwin)
|
|
EXTLDFLAGS = -extldflags "-static" $(null)
|
|
else
|
|
EXTLDFLAGS =
|
|
endif
|
|
|
|
ifeq ($(HAS_GO), GO)
|
|
GOPATH ?= $(shell $(GO) env GOPATH)
|
|
export PATH := $(GOPATH)/bin:$(PATH)
|
|
|
|
CGO_EXTRA_CFLAGS := -DSQLITE_MAX_VARIABLE_NUMBER=32766
|
|
CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
|
|
endif
|
|
|
|
ifeq ($(OS), Windows_NT)
|
|
GOFLAGS := -v -buildmode=exe
|
|
EXECUTABLE ?= $(EXECUTABLE).exe
|
|
else ifeq ($(OS), Windows)
|
|
GOFLAGS := -v -buildmode=exe
|
|
EXECUTABLE ?= $(EXECUTABLE).exe
|
|
else
|
|
GOFLAGS := -v
|
|
EXECUTABLE ?= $(EXECUTABLE)
|
|
endif
|
|
|
|
ifneq ($(DRONE_TAG),)
|
|
VERSION ?= $(DRONE_TAG)
|
|
else
|
|
VERSION ?= $(shell git describe --tags --always || git rev-parse --short HEAD)
|
|
endif
|
|
|
|
TAGS ?=
|
|
LDFLAGS ?= -X 'main.Version=$(VERSION)'
|
|
|
|
all: build
|
|
|
|
fmt:
|
|
@hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
$(GO) install mvdan.cc/gofumpt; \
|
|
fi
|
|
$(GOFMT) -w $(GOFILES)
|
|
|
|
vet:
|
|
$(GO) vet ./...
|
|
|
|
.PHONY: fmt-check
|
|
fmt-check:
|
|
@hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
$(GO) install mvdan.cc/gofumpt; \
|
|
fi
|
|
@diff=$$($(GOFMT) -d $(GOFILES)); \
|
|
if [ -n "$$diff" ]; then \
|
|
echo "Please run 'make fmt' and commit the result:"; \
|
|
echo "$${diff}"; \
|
|
exit 1; \
|
|
fi;
|
|
|
|
test:
|
|
@$(GO) test -v -cover -coverprofile coverage.txt ./... && echo "\n==>\033[32m Ok\033[m\n" || exit 1
|
|
|
|
install: $(GOFILES)
|
|
$(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)'
|
|
|
|
build: $(EXECUTABLE)
|
|
|
|
$(EXECUTABLE): $(GOFILES)
|
|
$(GO) build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o bin/$@
|
|
|
|
build_linux_amd64:
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/amd64/$(DEPLOY_IMAGE)
|
|
|
|
build_linux_i386:
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=386 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/i386/$(DEPLOY_IMAGE)
|
|
|
|
build_linux_arm64:
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm64/$(DEPLOY_IMAGE)
|
|
|
|
build_linux_arm:
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm/$(DEPLOY_IMAGE)
|
|
|
|
ssh-server:
|
|
adduser -h /home/drone-scp -s /bin/sh -D -S drone-scp
|
|
echo drone-scp:1234 | chpasswd
|
|
mkdir -p /home/drone-scp/.ssh
|
|
chmod 700 /home/drone-scp/.ssh
|
|
cat tests/.ssh/id_rsa.pub >> /home/drone-scp/.ssh/authorized_keys
|
|
cat tests/.ssh/test.pub >> /home/drone-scp/.ssh/authorized_keys
|
|
chmod 600 /home/drone-scp/.ssh/authorized_keys
|
|
chown -R drone-scp /home/drone-scp/.ssh
|
|
apk add --update openssh openrc
|
|
rm -rf /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key
|
|
sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
|
sed -i 's/AllowTcpForwarding no/AllowTcpForwarding yes/g' /etc/ssh/sshd_config
|
|
sed -i 's/^#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/g' /etc/ssh/sshd_config
|
|
sed -i 's/^#ListenAddress ::/ListenAddress ::/g' /etc/ssh/sshd_config
|
|
./tests/entrypoint.sh /usr/sbin/sshd -D &
|
|
|
|
coverage:
|
|
sed -i '/main.go/d' coverage.txt
|
|
|
|
clean:
|
|
$(GO) clean -x -i ./...
|
|
rm -rf coverage.txt $(EXECUTABLE) $(DIST)
|
|
|
|
version:
|
|
@echo $(VERSION)
|