From 6b9f1521a8a7982838abd11a2e5a572081a6c0bf Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 6 Sep 2019 23:48:22 +0200 Subject: [PATCH] Improved/Fixed CI package build --- .drone.yml | 8 ++--- .gitignore | 1 + Makefile | 78 ++++++++++++++++++++++++++++++++++++++++++----- config.ini.sample | 15 +++++++++ 4 files changed, 88 insertions(+), 14 deletions(-) create mode 100644 config.ini.sample diff --git a/.drone.yml b/.drone.yml index b87adf9..249c25f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -32,10 +32,6 @@ steps: commands: - export PATH=$PATH:$GOPATH/bin - make release - - pwd - - ls -hal dist - - ls -hal dist/binaries - - ls -hal dist/release depends_on: [ fetch-tags ] # Push the releases to our pseudo-s3-bucket @@ -50,7 +46,7 @@ steps: from_secret: aws_secret_access_key endpoint: https://storage.kolaente.de path_style: true - strip_prefix: dist/release/ - source: dist/release/* + strip_prefix: dist/zip/ + source: dist/zip/* target: /master/ depends_on: [ static ] \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7b4cf6c..7992873 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ astilectron-deps/ output/ Konfi-Castle-Kasino bind_linux_amd64.go +dist/ diff --git a/Makefile b/Makefile index c90211f..779a2c5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ DIST := dist +ELECTRON_VERSION := v4.0.1 IMPORT := git.mowie.cc/konrad/Konfi-Castle-Kasino SED_INPLACE := sed -i @@ -13,6 +14,8 @@ else endif endif +RELEASE_NAME := Konfi-Castle-Kasino + GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go") GOFMT ?= gofmt -s @@ -80,19 +83,19 @@ $(EXECUTABLE): $(SOURCES) go build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@ .PHONY: release -release: release-dirs release-windows release-linux release-darwin release-copy release-check +release: release-dirs release-windows release-linux release-darwin release-copy release-check release-os-package release-download-deps release-electron-prepare release-electron-bundle release-zip .PHONY: release-dirs release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release + mkdir -p $(DIST)/binaries $(DIST)/release $(DIST)/zip .PHONY: release-windows release-windows: @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ go get -u github.com/karalabe/xgo; \ fi - xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out Konfi-Castle-Kasino-$(VERSION) . -ifeq ($(CI),drone) + xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out $(RELEASE_NAME)-$(VERSION) . +ifneq ($(DRONE_WORKSPACE),'') mv /build/* $(DIST)/binaries endif @@ -101,8 +104,8 @@ release-linux: @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ go get -u github.com/karalabe/xgo; \ fi - xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/*' -out Konfi-Castle-Kasino-$(VERSION) . -ifeq ($(CI),drone) + xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/*' -out $(RELEASE_NAME)-$(VERSION) . +ifneq ($(DRONE_WORKSPACE),'') mv /build/* $(DIST)/binaries endif @@ -111,8 +114,8 @@ release-darwin: @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ go get -u github.com/karalabe/xgo; \ fi - xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out Konfi-Castle-Kasino-$(VERSION) . -ifeq ($(CI),drone) + xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out $(RELEASE_NAME)-$(VERSION) . +ifneq ($(DRONE_WORKSPACE),'') mv /build/* $(DIST)/binaries endif @@ -124,6 +127,65 @@ release-copy: release-check: cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) +.PHONY: release-download-deps +release-download-deps: + mkdir -p $(DIST)/astilectron-deps; \ + wget https://github.com/asticode/astilectron/archive/v0.30.0.zip -O $(DIST)/astilectron-deps/astilectron-v0.30.0.zip; \ + wget https://github.com/electron/electron/releases/download/$(ELECTRON_VERSION)/electron-$(ELECTRON_VERSION)-darwin-x64.zip -O $(DIST)/astilectron-deps/electron-darwin-amd64-$(ELECTRON_VERSION).zip; \ + wget https://github.com/electron/electron/releases/download/$(ELECTRON_VERSION)/electron-$(ELECTRON_VERSION)-linux-ia32.zip -O $(DIST)/astilectron-deps/electron-linux-ia32-$(ELECTRON_VERSION).zip; \ + wget https://github.com/electron/electron/releases/download/$(ELECTRON_VERSION)/electron-$(ELECTRON_VERSION)-linux-x64.zip -O $(DIST)/astilectron-deps/electron-linux-amd64-$(ELECTRON_VERSION).zip; \ + wget https://github.com/electron/electron/releases/download/$(ELECTRON_VERSION)/electron-$(ELECTRON_VERSION)-linux-armv7l.zip -O $(DIST)/astilectron-deps/electron-linux-arm-$(ELECTRON_VERSION).zip; \ + wget https://github.com/electron/electron/releases/download/$(ELECTRON_VERSION)/electron-$(ELECTRON_VERSION)-win32-ia32.zip -O $(DIST)/astilectron-deps/electron-win32-ia32-$(ELECTRON_VERSION).zip; \ + wget https://github.com/electron/electron/releases/download/$(ELECTRON_VERSION)/electron-$(ELECTRON_VERSION)-win32-x64.zip -O $(DIST)/astilectron-deps/electron-win32-amd64-$(ELECTRON_VERSION).zip; + +.PHONY: release-electron-prepare +release-electron-prepare: + mkdir -p $(DIST)/astilectron-deps/electron-darwin-amd64; \ + mkdir -p $(DIST)/astilectron-deps/electron-linux-ia32; \ + mkdir -p $(DIST)/astilectron-deps/electron-linux-amd64; \ + mkdir -p $(DIST)/astilectron-deps/electron-linux-arm; \ + mkdir -p $(DIST)/astilectron-deps/electron-win32-ia32; \ + mkdir -p $(DIST)/astilectron-deps/electron-win32-amd64; \ + unzip $(DIST)/astilectron-deps/astilectron-v0.30.0.zip -d $(DIST)/astilectron-deps/; \ + mv $(DIST)/astilectron-deps/astilectron-0.30.0 $(DIST)/astilectron-deps/astilectron; \ + unzip $(DIST)/astilectron-deps/electron-darwin-amd64-$(ELECTRON_VERSION).zip -d $(DIST)/astilectron-deps/electron-darwin-amd64; \ + unzip $(DIST)/astilectron-deps/electron-linux-ia32-$(ELECTRON_VERSION).zip -d $(DIST)/astilectron-deps/electron-linux-ia32; \ + unzip $(DIST)/astilectron-deps/electron-linux-amd64-$(ELECTRON_VERSION).zip -d $(DIST)/astilectron-deps/electron-linux-amd64; \ + unzip $(DIST)/astilectron-deps/electron-linux-arm-$(ELECTRON_VERSION).zip -d $(DIST)/astilectron-deps/electron-linux-arm; \ + unzip $(DIST)/astilectron-deps/electron-win32-ia32-$(ELECTRON_VERSION).zip -d $(DIST)/astilectron-deps/electron-win32-ia32; \ + unzip $(DIST)/astilectron-deps/electron-win32-amd64-$(ELECTRON_VERSION).zip -d $(DIST)/astilectron-deps/electron-win32-amd64; + +.PHONY: release-os-package +release-os-package: + $(foreach file,$(filter-out %.sha256,$(wildcard $(DIST)/release/$(EXECUTABLE)-*)),mkdir $(file)-full/astilectron-deps/vendor -p;mkdir $(file)-full/astilectron-deps/vendor/astilectron -p;mv $(file) $(file)-full/;mv $(file).sha256 $(file)-full/; cp config.ini.sample $(file)-full/config.ini; cp LICENSE $(file)-full/; cp assets/ $(file)-full/ -R; cp tpl $(file)-full/ -R; cp gopher.png $(file)-full/; cp gopher.icns $(file)-full/; ) + +.PHONY: release-electron-bundle +release-electron-bundle: + cp -r $(DIST)/astilectron-deps/electron-darwin-amd64 $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-darwin-10.6-amd64-full/astilectron-deps/vendor/electron-darwin-amd64; \ + cp -r $(DIST)/astilectron-deps/electron-darwin-amd64 $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-darwin-10.6-amd64-full/astilectron-deps/vendor/electron-darwin-amd64; \ + cp -r $(DIST)/astilectron-deps/electron-linux-ia32 $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-linux-386-full/astilectron-deps/vendor/electron-linux-ia32; \ + cp -r $(DIST)/astilectron-deps/electron-linux-amd64 $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-linux-amd64-full/astilectron-deps/vendor/electron-linux-amd64; \ + cp -r $(DIST)/astilectron-deps/electron-linux-arm $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-linux-arm-5-full/astilectron-deps/vendor/electron-linux-arm; \ + cp -r $(DIST)/astilectron-deps/electron-linux-arm $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-linux-arm-6-full/astilectron-deps/vendor/electron-linux-arm; \ + cp -r $(DIST)/astilectron-deps/electron-linux-arm $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-linux-arm-7-full/astilectron-deps/vendor/electron-linux-arm; \ + cp -r $(DIST)/astilectron-deps/electron-linux-arm $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-linux-arm64-full/astilectron-deps/vendor/electron-linux-arm; \ + cp -r $(DIST)/astilectron-deps/electron-win32-ia32 $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-windows-4.0-386.exe-full/astilectron-deps/vendor/electron-win32-ia32; \ + cp -r $(DIST)/astilectron-deps/electron-win32-amd64 $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-windows-4.0-amd64.exe-full/astilectron-deps/vendor/electron-win32-amd64; \ + cp -r $(DIST)/astilectron-deps/astilectron $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-darwin-10.6-386-full/astilectron-deps/vendor/; \ + cp -r $(DIST)/astilectron-deps/astilectron $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-darwin-10.6-amd64-full/astilectron-deps/vendor/; \ + cp -r $(DIST)/astilectron-deps/astilectron $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-linux-386-full/astilectron-deps/vendor/; \ + cp -r $(DIST)/astilectron-deps/astilectron $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-linux-amd64-full/astilectron-deps/vendor/; \ + cp -r $(DIST)/astilectron-deps/astilectron $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-linux-arm-5-full/astilectron-deps/vendor/; \ + cp -r $(DIST)/astilectron-deps/astilectron $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-linux-arm-6-full/astilectron-deps/vendor/; \ + cp -r $(DIST)/astilectron-deps/astilectron $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-linux-arm-7-full/astilectron-deps/vendor/; \ + cp -r $(DIST)/astilectron-deps/astilectron $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-linux-arm64-full/astilectron-deps/vendor/; \ + cp -r $(DIST)/astilectron-deps/astilectron $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-windows-4.0-386.exe-full/astilectron-deps/vendor/; \ + cp -r $(DIST)/astilectron-deps/astilectron $(DIST)/release/$(RELEASE_NAME)-$(VERSION)-windows-4.0-amd64.exe-full/astilectron-deps/vendor/; + +.PHONY: release-zip +release-zip: + $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),cd $(file); zip -r ../../zip/$(shell basename $(file)).zip *; cd ../../../; ) + .PHONY: lint lint: @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ diff --git a/config.ini.sample b/config.ini.sample new file mode 100644 index 0000000..cacbf8d --- /dev/null +++ b/config.ini.sample @@ -0,0 +1,15 @@ +; Das Adminpasswort, wird benötigt, um sich unter /admin einzuloggen +AdminPassword = geheim + +; 0 = Konfis spielen selbstständig +; 1 = Gemeinden spielen gegeneinancer +Mode = 1 + +; Serverkram +; Das Interface inkl. Port, auf dem der Webserver läuft. Muss komplett mit IP-Adresse vorhanden sein. +Interface = 127.0.0.1:8080 +; Hier wird die Datenbank gespeichert +DBFile = ./data.db +; Ob Fenster geöffnet werden sollen, oder nicht. +OpenWindows = true +OpenBrowser = false \ No newline at end of file