forked from anhbh310/gotify2telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
45 lines (34 loc) · 2.1 KB
/
Makefile
File metadata and controls
45 lines (34 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
BUILDDIR=./build
GOTIFY_VERSION=v2.9.0
PLUGIN_NAME=telegram-plugin
PLUGIN_ENTRY=plugin.go
GO_VERSION=`cat $(BUILDDIR)/gotify-server-go-version`
DOCKER_BUILD_IMAGE=gotify/build
DOCKER_WORKDIR=/proj
DOCKER_RUN=docker run --rm -v "$$PWD/.:${DOCKER_WORKDIR}" -v "`go env GOPATH`/pkg/mod/.:/go/pkg/mod:ro" -w ${DOCKER_WORKDIR}
DOCKER_GO_BUILD=go build -mod=readonly -a -installsuffix cgo -ldflags "$$LD_FLAGS" -buildmode=plugin
GOMOD_CAP=go run github.com/gotify/plugin-api/cmd/gomod-cap
download-tools:
GO111MODULE=off go get -u github.com/gotify/plugin-api/cmd/gomod-cap
create-build-dir:
mkdir -p ${BUILDDIR} || true
update-go-mod: create-build-dir
wget -O ${BUILDDIR}/gotify-server.mod https://raw.githubusercontent.com/gotify/server/${GOTIFY_VERSION}/go.mod
$(GOMOD_CAP) -from ${BUILDDIR}/gotify-server.mod -to go.mod
rm ${BUILDDIR}/gotify-server.mod || true
go mod tidy
get-gotify-server-go-version: create-build-dir
rm ${BUILDDIR}/gotify-server-go-version || true
wget -O ${BUILDDIR}/gotify-server-go-version https://raw.githubusercontent.com/gotify/server/${GOTIFY_VERSION}/GO_VERSION
build-linux-amd64: get-gotify-server-go-version update-go-mod
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-amd64 ${DOCKER_GO_BUILD} -o ${BUILDDIR}/${PLUGIN_NAME}-linux-amd64${FILE_SUFFIX}.so ${DOCKER_WORKDIR}
build-linux-arm-7: get-gotify-server-go-version update-go-mod
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-arm-7 ${DOCKER_GO_BUILD} -o ${BUILDDIR}/${PLUGIN_NAME}-linux-arm-7${FILE_SUFFIX}.so ${DOCKER_WORKDIR}
build-linux-arm64: get-gotify-server-go-version update-go-mod
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-arm64 ${DOCKER_GO_BUILD} -o ${BUILDDIR}/${PLUGIN_NAME}-linux-arm64${FILE_SUFFIX}.so ${DOCKER_WORKDIR}
build: build-linux-arm-7 build-linux-amd64 build-linux-arm64
lint:
golangci-lint run ./...
build-plugin: create-build-dir
go build -mod=readonly -buildmode=plugin -o ${BUILDDIR}/${PLUGIN_NAME}.so ${PLUGIN_ENTRY}
.PHONY: download-tools create-build-dir update-go-mod get-gotify-server-go-version build-linux-amd64 build-linux-arm-7 build-linux-arm64 build lint build-plugin