From 4c7ecaa0d494377a19ddae06750cd24b2872b1bb Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Sat, 2 Mar 2019 09:59:03 +0800 Subject: [PATCH] use new plugin template --- .travis.yml | 32 ++++++++------------------------ Makefile | 32 +++++++++++++------------------- 2 files changed, 21 insertions(+), 43 deletions(-) diff --git a/.travis.yml b/.travis.yml index e1bd065..e3d2868 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,44 +1,28 @@ -sudo: required -dist: xenial language: go go: - "1.11.5" -addons: - apt: - packages: - - mingw-w64 - - gcc-aarch64-linux-gnu - - g++-aarch64-linux-gnu - - gcc-arm-linux-gnueabihf - - g++-arm-linux-gnueabihf +services: + - docker notifications: email: false env: - - GO111MODULE=on + - GO111MODULE=on GOTIFY_VERSIONS="v2.0.0 master" before_install: - make download-tools - - GO111MODULE=off go get gopkg.in/mikefarah/yq.v2 + - go get -d script: - - make check + - go test ./... before_deploy: - > - if ! [ "$BEFORE_DEPLOY_RUN" ]; then - export BEFORE_DEPLOY_RUN=1; - for TARGET in master 44f905d; do - TARGET_GO_VERSION=$(curl -fsSL "https://raw.githubusercontent.com/gotify/server/$TARGET/.travis.yml" | yq.v2 read - go\[0\]); - eval "$(gimme ${TARGET_GO_VERSION})"; - CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make GOTIFY_VERSION=${TARGET} build; - CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ CGO_ENABLED=1 GOOS=linux GOARCH=arm64 make GOTIFY_VERSION=${TARGET} build; - CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 make GOTIFY_VERSION=${TARGET} build; - done - ls -lath build; - fi + for TARGET in $GOTIFY_VERSIONS; do + make GOTIFY_VERSION="$TARGET" FILE_SUFFIX="-for-gotify-$TARGET" build; + done deploy: - provider: releases diff --git a/Makefile b/Makefile index 301f635..c199f50 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ BUILDDIR=./build GOTIFY_VERSION=master PLUGIN_NAME=broadcasts -LICENSE_DIR=./OPENSOURCELICENSE +PLUGIN_ENTRY=plugin.go +GO_VERSION=`cat $(BUILDDIR)/gotify-server-go-version` download-tools: GO111MODULE=off go get -u github.com/gotify/plugin-api/cmd/gomod-cap @@ -9,32 +10,25 @@ download-tools: create-build-dir: mkdir -p ${BUILDDIR} || true -check-go: - go test ./... - update-go-mod: create-build-dir wget -LO ${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 -check-go-mod: create-build-dir - wget -LO ${BUILDDIR}/gotify-server.mod https://raw.githubusercontent.com/gotify/server/${GOTIFY_VERSION}/go.mod - gomod-cap -from ${BUILDDIR}/gotify-server.mod -to go.mod -check=true - rm ${BUILDDIR}/gotify-server.mod || true +get-gotify-server-go-version: create-build-dir + rm ${BUILDDIR}/gotify-server-go-version || true + wget -LO ${BUILDDIR}/gotify-server-go-version https://raw.githubusercontent.com/gotify/server/${GOTIFY_VERSION}/GO_VERSION -build: create-build-dir update-go-mod - CGO_ENABLED=1 go build -o build/${PLUGIN_NAME}-$$(go env -json | jq -r ".GOOS")-$$(go env -json | jq -r ".GOARCH")${GOARM}-for-gotify-${GOTIFY_VERSION}.so -buildmode=plugin +build-linux-amd64: get-gotify-server-go-version update-go-mod + docker run --rm -v "$$PWD/.:/proj" -w /proj gotify/build:$(GO_VERSION)-linux-amd64 go build -a -installsuffix cgo -ldflags "-w -s" -buildmode=plugin -o build/${PLUGIN_NAME}-linux-amd64${FILE_SUFFIX}.so /proj -extract-licenses: - go mod vendor - mkdir ${LICENSE_DIR} || true - for LICENSE in $(shell find vendor/* -name LICENSE); do \ - DIR=`echo $$LICENSE | tr "/" _ | sed -e 's/vendor_//; s/_LICENSE//'` ; \ - cp $$LICENSE ${LICENSE_DIR}/$$DIR ; \ - done +build-linux-arm-7: get-gotify-server-go-version update-go-mod + docker run --rm -v "$$PWD/.:/proj" -w /proj gotify/build:$(GO_VERSION)-linux-arm-7 go build -a -installsuffix cgo -ldflags "-w -s" -buildmode=plugin -o build/${PLUGIN_NAME}-linux-arm-7${FILE_SUFFIX}.so /proj +build-linux-arm64: get-gotify-server-go-version update-go-mod + docker run --rm -v "$$PWD/.:/proj" -w /proj gotify/build:$(GO_VERSION)-linux-arm64 go build -a -installsuffix cgo -ldflags "-w -s" -buildmode=plugin -o build/${PLUGIN_NAME}-linux-arm64${FILE_SUFFIX}.so /proj -check: check-go check-go-mod +build: build-linux-arm-7 build-linux-amd64 build-linux-arm64 -.PHONY: build download-tools check-go check-go-mod update-go-mod +.PHONY: build