Skip to content

Commit

Permalink
Add drone auto build capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
tystuyfzand committed Mar 15, 2022
1 parent 6ad97fc commit ad7fbf7
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 4 deletions.
56 changes: 56 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ 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}
go mod tidy

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}
Expand Down

0 comments on commit ad7fbf7

Please sign in to comment.