diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..8d98377 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,56 @@ +kind: pipeline +type: docker +name: default + +steps: + - name: build + image: docker:dind + volumes: + - name: dockersock + path: /var/run + - name: build + path: /build + commands: + - echo "Building gotify version $GOTIFY_VERSION" + - sleep 5 # give docker enough time to start + - docker ps -a + - apk --no-cache add build-base git go + - export PATH=$PATH:$HOME/go/bin + - make -e build + - ls build + - cp build/*.so /build + - name: publish + image: tystuyfzand/drone-github-release + volumes: + - name: build + path: /build + settings: + api_key: + from_secret: github_api_key + files: + - /build/*.so + title: "MQTT for Gotify ${GOTIFY_VERSION}" + tag_name: "latest-gotify-${GOTIFY_VERSION}" + checksum: + - md5 + - sha1 + - sha256 + - sha512 + +services: + - name: docker + image: docker:dind + privileged: true + volumes: + - name: dockersock + path: /var/run + +volumes: + - name: dockersock + temp: {} + - name: build + temp: {} + +trigger: + event: + - custom \ No newline at end of file diff --git a/Makefile b/Makefile index c2cc5ae..b7dadd9 100644 --- a/Makefile +++ b/Makefile @@ -5,17 +5,17 @@ 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_RUN=docker run --rm -v "$$PWD/.:${DOCKER_WORKDIR}" -v "`go env GOPATH`/pkg/mod/.:/go/pkg/mod" -w ${DOCKER_WORKDIR} DOCKER_GO_BUILD=go build -mod=readonly -a -installsuffix cgo -ldflags "$$LD_FLAGS" -buildmode=plugin download-tools: - GO111MODULE=off go get -u github.com/gotify/plugin-api/cmd/gomod-cap + go install github.com/gotify/plugin-api/cmd/gomod-cap@latest create-build-dir: mkdir -p ${BUILDDIR} || true update-go-mod: create-build-dir download-tools - wget -LO ${BUILDDIR}/gotify-server.mod https://raw.githubusercontent.com/gotify/server/${GOTIFY_VERSION}/go.mod + 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 edit -require=github.com/gotify/server$(shell echo "/${GOTIFY_VERSION}" | egrep -o "^/v[2-9][0-9]*")@${GOTIFY_VERSION} @@ -23,7 +23,7 @@ update-go-mod: create-build-dir download-tools 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 + 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}