diff --git a/.drone1.yml b/.drone1.yml index c90dae108e..82ade9693f 100644 --- a/.drone1.yml +++ b/.drone1.yml @@ -111,30 +111,30 @@ steps: image: karalabe/xgo-latest:latest pull: true environment: - TAGS: bindata sqlite GOPATH: /srv/app commands: - make release-windows + - mv /build/* $(DIST)/binaries depends_on: [ before-static-build ] - name: static-build-linux image: karalabe/xgo-latest:latest pull: true environment: - TAGS: bindata sqlite GOPATH: /srv/app commands: - make release-linux + - mv /build/* $(DIST)/binaries depends_on: [ before-static-build ] - name: static-build-darwin image: karalabe/xgo-latest:latest pull: true environment: - TAGS: bindata sqlite GOPATH: /srv/app commands: - make release-darwin + - mv /build/* $(DIST)/binaries depends_on: [ before-static-build ] - name: after-build-static @@ -180,6 +180,49 @@ steps: target: /master/ depends_on: [ sign-release ] + # Build a debian package and push it to our bucket + - name: build-deb + image: kolaente/fpm + pull: true + commands: + - make build-deb + depends_on: [ static-build-linux ] + + - name: deb-structure + image: kolaente/reprepro + pull: true + environment: + GPG_PRIVATE_KEY: + from_secret: gpg_privatekey + commands: + - export GPG_TTY=$(tty) + - gpg -qk + - echo "use-agent" >> ~/.gnupg/gpg.conf + - gpgconf --kill gpg-agent + - echo $GPG_PRIVATE_KEY > ~/frederik.gpg + - gpg --import ~/frederik.gpg + - mkdir debian/conf -p + - cp build/reprepro-dist-conf debian/conf/distributions + - make reprepro + depends_on: [ build-deb ] + + # Push the releases to our pseudo-s3-bucket + - name: release-deb + image: plugins/s3:1 + pull: true + settings: + bucket: vikunja-deb + access_key: + from_secret: aws_access_key_id + secret_key: + from_secret: aws_secret_access_key + endpoint: https://storage.kolaente.de + path_style: true + strip_prefix: debian + source: debian/* + target: / + depends_on: [ deb-structure ] + # Build the docker image and push it to docker hub - name: docker image: plugins/docker @@ -262,30 +305,30 @@ steps: image: karalabe/xgo-latest:latest pull: true environment: - TAGS: bindata sqlite GOPATH: /srv/app commands: - make release-windows + - mv /build/* $(DIST)/binaries depends_on: [ before-static-build ] - name: static-build-linux image: karalabe/xgo-latest:latest pull: true environment: - TAGS: bindata sqlite GOPATH: /srv/app commands: - make release-linux + - mv /build/* $(DIST)/binaries depends_on: [ before-static-build ] - name: static-build-darwin image: karalabe/xgo-latest:latest pull: true environment: - TAGS: bindata sqlite GOPATH: /srv/app commands: - make release-darwin + - mv /build/* $(DIST)/binaries depends_on: [ before-static-build ] - name: after-build-static @@ -331,6 +374,49 @@ steps: target: /${DRONE_TAG##v}/ depends_on: [ sign-release ] + # Build a debian package and push it to our bucket + - name: build-deb + image: kolaente/fpm + pull: true + commands: + - make build-deb + depends_on: [ static-build-linux ] + + - name: deb-structure + image: kolaente/reprepro + pull: true + environment: + GPG_PRIVATE_KEY: + from_secret: gpg_privatekey + commands: + - export GPG_TTY=$(tty) + - gpg -qk + - echo "use-agent" >> ~/.gnupg/gpg.conf + - gpgconf --kill gpg-agent + - echo $GPG_PRIVATE_KEY > ~/frederik.gpg + - gpg --import ~/frederik.gpg + - mkdir debian/conf -p + - cp build/reprepro-dist-conf debian/conf/distributions + - make reprepro + depends_on: [ build-deb ] + + # Push the releases to our pseudo-s3-bucket + - name: release-deb + image: plugins/s3:1 + pull: true + settings: + bucket: vikunja-deb + access_key: + from_secret: aws_access_key_id + secret_key: + from_secret: aws_secret_access_key + endpoint: https://storage.kolaente.de + path_style: true + strip_prefix: debian + source: debian/* + target: / + depends_on: [ deb-structure ] + # Build the docker image and push it to docker hub - name: docker image: plugins/docker diff --git a/.gitignore b/.gitignore index 41d2d73398..55a93ed7ee 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ dist/ cover.* /vikunja Test_* -bin/ \ No newline at end of file +bin/ +secrets +*.deb +debian/ \ No newline at end of file diff --git a/Makefile b/Makefile index 9c32aa5222..a974a5dcef 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,18 @@ else endif endif +ifeq ($(DRONE_WORKSPACE),'') + BINLOCATION := $(EXECUTABLE) +else + BINLOCATION := $(DIST)/binaries/$(EXECUTABLE)-$(VERSION)-linux-amd64 +endif + +ifeq ($(VERSION),master) + PKGVERSION := $(shell git describe --tags --always --abbrev=10 | sed 's/-/+/' | sed 's/^v//' | sed 's/-g/-/') +else + PKGVERSION := $(VERSION) +endif + VERSION := $(shell echo $(VERSION) | sed 's/\//\-/g') .PHONY: all @@ -104,9 +116,6 @@ release-windows: go install $(GOFLAGS) github.com/karalabe/xgo; \ fi xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out vikunja-$(VERSION) . -ifneq ($(DRONE_WORKSPACE),'') - mv /build/* $(DIST)/binaries -endif .PHONY: release-linux release-linux: @@ -114,9 +123,6 @@ release-linux: go install $(GOFLAGS) github.com/karalabe/xgo; \ fi xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/*' -out vikunja-$(VERSION) . -ifneq ($(DRONE_WORKSPACE),'') - mv /build/* $(DIST)/binaries -endif .PHONY: release-darwin release-darwin: @@ -124,9 +130,6 @@ release-darwin: go install $(GOFLAGS) github.com/karalabe/xgo; \ fi xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out vikunja-$(VERSION) . -ifneq ($(DRONE_WORKSPACE),'') - mv /build/* $(DIST)/binaries -endif .PHONY: release-copy release-copy: @@ -146,6 +149,15 @@ release-os-package: release-zip: $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),cd $(file); zip -r ../../zip/$(shell basename $(file)).zip *; cd ../../../; ) +# Builds a deb package using fpm from a previously created binary (using make build) +.PHONY: build-deb +build-deb: + fpm -s dir -t deb --url https://vikunja.io -n vikunja -v $(PKGVERSION) --license GPLv3 --directories /opt/vikunja --after-install ./build/after-install.sh --description 'Vikunja is an open-source todo application, written in Go. It lets you create lists,tasks and share them via teams or directly between users.' -m maintainers@vikunja.io ./$(BINLOCATION)=/opt/vikunja/vikunja ./templates=/opt/vikunja ./config.yml.sample=/etc/vikunja/config.yml; + +.PHONY: reprepro +reprepro: + reprepro_expect debian includedeb strech ./$(EXECUTABLE)_$(PKGVERSION)_amd64.deb + .PHONY: got-swag got-swag: do-the-swag @diff=$$(git diff docs/swagger/swagger.json); \ diff --git a/build/after-install.sh b/build/after-install.sh new file mode 100644 index 0000000000..8e00976055 --- /dev/null +++ b/build/after-install.sh @@ -0,0 +1,8 @@ +#!/bin/bash +ln -s /opt/vikunja/vikunja /usr/bin/vikunja + +# Fix the config to contain proper values +NEW_SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) +sed -i "s//$NEW_SECRET/g" /etc/vikunja/config.yml +sed -i "s//\/opt\/vikunja\//g" /etc/vikunja/config.yml +sed -i "s/Path: \"\.\/vikunja.db\"/Path: \"\\/opt\/vikunja\/vikunja.db\"/g" /etc/vikunja/config.yml diff --git a/build/reprepro-dist-conf b/build/reprepro-dist-conf new file mode 100644 index 0000000000..8ea7e4c7b5 --- /dev/null +++ b/build/reprepro-dist-conf @@ -0,0 +1,8 @@ +Origin: dl.vikunja.io +Label: Vikunja +Codename: strech +Architectures: amd64 +Components: main +Description: The debian repo for Vikunja builds. +SignWith: yes +Pull: strech diff --git a/config.yml.sample b/config.yml.sample index fd9071918c..d2203d35c8 100644 --- a/config.yml.sample +++ b/config.yml.sample @@ -2,7 +2,7 @@ service: # This token is used to verify issued JWT tokens. # Default is a random token which will be generated at each startup of vikunja. # (This means all already issued tokens will be invalid once you restart vikunja) - JWTSecret: "cei6gaezoosah2bao3ieZohkae5aicah" + JWTSecret: "" # The interface on which to run the webserver interface: ":3456" # The URL of the frontend, used to send password reset emails. @@ -10,7 +10,7 @@ service: # The base path on the file system where the binary and assets are. # Vikunja will also look in this path for a config file, so you could provide only this variable to point to a folder # with a config file which will then be used. - rootpath: + rootpath: # The number of items which gets returned per page pagecount: 50 # If set to true, enables a /metrics endpoint for prometheus to collect metrics about the system