Skip to content

Commit

Permalink
use new plugin template
Browse files Browse the repository at this point in the history
  • Loading branch information
eternal-flame-AD committed Mar 2, 2019
1 parent eb7cb60 commit 4c7ecaa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 43 deletions.
32 changes: 8 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 13 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
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

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

0 comments on commit 4c7ecaa

Please sign in to comment.