From 8efbfc6d72db3e82811b9219882c7e16d548e8ce Mon Sep 17 00:00:00 2001 From: Stash Dev Date: Sun, 10 Feb 2019 04:16:29 -0800 Subject: [PATCH] Added Travis CI --- .goreleaser.yml | 64 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 34 +++++++++++++++++++++ Makefile | 11 ++++--- README.md | 4 ++- main_test.go | 7 +++++ scripts/cross-compile.sh | 10 +++++++ 6 files changed, 125 insertions(+), 5 deletions(-) create mode 100644 .goreleaser.yml create mode 100644 .travis.yml create mode 100644 main_test.go create mode 100755 scripts/cross-compile.sh diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 000000000..238fea065 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,64 @@ +project_name: stash +before: + hooks: + - go mod download +builds: + - binary: stash-win + ldflags: + - "-extldflags '-static'" + env: + - CGO_ENABLED=1 + - CC=x86_64-w64-mingw32-gcc + - CXX=x86_64-w64-mingw32-g++ + flags: + - -tags + - extended + goos: + - windows + goarch: + - amd64 + - binary: stash-osx + env: + - CGO_ENABLED=1 + - CC=o64-clang + - CXX=o64-clang++ + flags: + - -tags + - extended + goos: + - darwin + goarch: + - amd64 + - binary: stash-linux + env: + - CGO_ENABLED=1 + flags: + - -tags + - extended + goos: + - linux + goarch: + - amd64 +archive: + format: tar.gz + format_overrides: + - goos: windows + format: zip + name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}-{{.Arch}}" + replacements: + amd64: 64bit + 386: 32bit + arm: ARM + arm64: ARM64 + darwin: macOS + linux: Linux + windows: Windows + openbsd: OpenBSD + netbsd: NetBSD + freebsd: FreeBSD + dragonfly: DragonFlyBSD + files: + - README.md + - LICENSE +release: + draft: true \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..27b1adc03 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,34 @@ +language: go +go: +- 1.11.x +services: +- docker +before_install: +- echo -e "machine github.com\n login $CI_USER_TOKEN" > ~/.netrc +- cd ui/v1 +- yarn install +- ./node_modules/@angular/cli/bin/ng build --prod +- cd ../.. +script: go test +before_deploy: +- docker pull bepsays/ci-goreleaser +- go get -u github.com/gobuffalo/packr/v2/packr2 +- sh ./scripts/cross-compile.sh +- git tag -f v0.0.0-alpha +- git push -f --tags +deploy: + provider: releases + api_key: + secure: tGJ2q62CfPdayid2qEtW2aGRhMgCl3lBXYYQqp3eH0vFgIIf6cs7IDX7YC/x3XKMEQ/iMLZmtCXZvSTqNrD6Sk7MSnt30GIs+4uxIZDnnd8mV5X3K4n4gjD+NAORc4DrQBvUGrYMKJsR5gtkH0nu6diWb1o1If7OiJEuCPRhrmQYcza7NUdABnA9Z2wn2RNUV9Ga33WUCqLMEU5GtNBlfQPiP/khCQrqn/ocR6wUjYut3J6YagzqH4wsfJi3glHyWtowcNIw1LZi5zFxHD/bRBT4Tln7yypkjWNq9eQILA6i6kRUGf7ggyTx26/k8n4tnu+QD0vVh4EcjlThpU/LGyUXzKrrxjRwaDZnM0oYxg5AfHcBuAiAdo0eWnV3lEWRfTJMIVb9MPf4qDmzR4RREfB5OXOxwq3ODeCcJE8sTIMD/wBPZrlqS/QrRpND2gn2X4snkVukN9t9F4CMTFMtVSzFV7TDJW5E5Lq6VEExulteQhs6kcK9NRPNAaLgRQAw7X9kVWfDtiGUP+fE2i8F9Bo8bm7sOT5O5VPMPykx3EgeNg1IqIgMTCsMlhMJT4xBJoQUgmd2wWyf3Ryw+P+sFgdb5Sd7+lFgJBjMUUoOxMxAOiEgdFvCXcr+/Udyz2RdtetU1/6VzXzLPcKOw0wubZeBkISqu7o9gpfdMP9Eq00= + file: + - dist/stash-osx + - dist/stash-win.exe + - dist/stash-linux + skip_cleanup: true + overwrite: true + on: + repo: stashapp/stash + branch: master +branches: + except: + - /^v\d+\.\d\.\d.*/ # don't build tags \ No newline at end of file diff --git a/Makefile b/Makefile index f35843c5c..dbc1bc3a1 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ -gqlgen: - go run scripts/gqlgen.go - build: - CGO_ENABLED=1 packr2 build -mod=vendor -v \ No newline at end of file + CGO_ENABLED=1 packr2 build -mod=vendor -v + +install: + packr2 install + +gqlgen: + go run scripts/gqlgen.go \ No newline at end of file diff --git a/README.md b/README.md index cea93f5ad..a1b205abe 100644 --- a/README.md +++ b/README.md @@ -77,4 +77,6 @@ TODO #### Notes for the dev -https://blog.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/ \ No newline at end of file +https://blog.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/ + +`docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash -i -t bepsays/ci-goreleaser:1.11-2 /bin/bash` \ No newline at end of file diff --git a/main_test.go b/main_test.go new file mode 100644 index 000000000..3c2556a09 --- /dev/null +++ b/main_test.go @@ -0,0 +1,7 @@ +package main + +import "testing" + +func TestStub(t *testing.T) { + +} \ No newline at end of file diff --git a/scripts/cross-compile.sh b/scripts/cross-compile.sh new file mode 100755 index 000000000..4c98a6904 --- /dev/null +++ b/scripts/cross-compile.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +SETUP="export GO111MODULE=on; export CGO_ENABLED=1; go get -u github.com/gobuffalo/packr/v2/packr2;" +WINDOWS="GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ packr2 build -o dist/stash-win.exe -ldflags \"-extldflags '-static'\" -tags extended -v -mod=vendor;" +DARWIN="GOOS=darwin GOARCH=amd64 CC=o64-clang CXX=o64-clang++ packr2 build -o dist/stash-osx -tags extended -v -mod=vendor;" +LINUX="packr2 build -o dist/stash-linux -v -mod=vendor;" + +COMMAND="$SETUP $WINDOWS $DARWIN $LINUX" + +docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash bepsays/ci-goreleaser:1.11-2 /bin/bash -c "$COMMAND" \ No newline at end of file