2018-03-07 23:09:25 +01:00
# Semaphore Tasks
# These tasks should be used to build and develop Semaphore
#
# Tasks without a `desc:` field are intended mainly to be called
# internally by other tasks and therefore are not listed when running `task` or `task -l`
2018-03-10 23:34:18 +01:00
version : '2'
tasks :
all :
desc : Install, Compile, Test and Build Semaphore for local architecture
cmds :
- deps
- compile
- test
- build:local
deps :
desc : Install all dependencies
cmds :
2018-03-11 15:22:50 +01:00
- task : deps:tools
2018-03-10 23:34:18 +01:00
- task : deps:be
- task : deps:fe
deps:be :
2018-03-11 15:22:50 +01:00
desc : Vendor application dependencies
2018-03-10 23:34:18 +01:00
cmds :
2018-03-11 15:22:50 +01:00
- dep ensure -vendor-only
2018-03-10 23:34:18 +01:00
deps:fe :
desc : Installs npm requirements for front end from package.json
dir : public
cmds :
- git submodule update --init --recursive
- npm i -g less pug-cli
- npm i async
2018-03-11 15:22:50 +01:00
deps:tools :
desc : Installs tools needed
2018-03-10 23:34:18 +01:00
dir : public
cmds :
- npm install -g nodemon
2018-03-11 15:22:50 +01:00
- go get -u github.com/golang/dep/cmd/dep
2018-03-10 23:34:18 +01:00
- go get github.com/cespare/reflex
2018-03-11 15:22:50 +01:00
- go get -u github.com/gobuffalo/packr/...
- go get github.com/mitchellh/gox
- go get -u github.com/haya14busa/goverage
2018-03-10 23:34:18 +01:00
compile :
desc : Generates compiled frontend and backend resources (must be in this order)
cmds :
- task : compile:fe
- task : compile:be
compile:fe :
desc : Runs less, pug and node
dir : public
sources :
- css/semaphore.less
- html/*.pug
- html/**/*.pug
generates :
- css/semaphore.css
- html/*.html
- html/**/*.html
- js/bundle.json
cmds :
- lessc css/semaphore.less > css/semaphore.css
- pug $(find ./html/ -name "*.pug")
- node ./bundler.js
compile:be :
desc : Runs Packr for static assets
sources :
- public/*
- db/migrations/*
generates :
- db/db-packr.go
- api/api-packr.go
cmds :
- packr
2018-03-08 00:42:11 +01:00
- go run util/version_gen/generator.go {{ if .TAG }}{{ .TAG }}{{ else }}{{ if .SEMAPHORE_VERSION }}{{ .SEMAPHORE_VERSION }}{{ else }}{{ .BRANCH }}-{{ .SHA }}-{{ .TIMESTAMP }}{{ if .DIRTY }}-dirty{{ end }}{{ end }}{{end}}
vars :
TAG :
sh : git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null | sed -n 's/^\([^^~]\{1,\}\)\(\^0\)\{0,1\}$/\1/p'
BRANCH :
sh : git rev-parse --abbrev-ref HEAD
DIRTY :
sh : git status --porcelain
SHA :
sh : git log --pretty=format:'%h' -n 1
TIMESTAMP :
sh : date +%s
2018-03-10 23:34:18 +01:00
watch :
desc : Watch fe and be file changes and rebuild
dir : public
cmds :
- task : watch:fe
- task : watch:be
watch:be :
cmds :
- reflex -r '\.go$' -R '^public/vendor/' -R '^node_modules/' -s -d none -- sh -c 'go build -i -o /tmp/semaphore_bin cli/main.go && /tmp/semaphore_bin -config $(pwd)/config.json'
watch:fe :
dir : public
cmds :
- nodemon -w js -i bundle.js -e js bundler.js &
- nodemon -w css -e less --exec "lessc css/semaphore.less > css/semaphore.css" &
- pug -w -P --doctype html $(find ./html/ -name "*.pug") &
build :
desc : Build a full set of release binaries
dir : cli
cmds :
- gox -output="../bin/semaphore_{{"{{"}}.OS{{"}}"}}_{{"{{"}}.Arch{{"}}"}}" ./...
build:local :
desc : Build a binary for the current architecture
dir : cli
cmds :
- go build -o ../bin/semaphore
test :
desc : Run go code tests
cmds :
- go vet ./...
2018-03-11 01:52:31 +01:00
# 2> /dev/null makes goverage less noisy about pattern matching
# if no tests exist but will still print failing test results
- goverage -v -coverprofile=coverage.out ./... 2> /dev/null
2018-03-10 23:34:18 +01:00
ci:artifacts :
cmds :
- rsync -a bin/semaphore_* $CIRCLE_ARTIFACTS/
release :
cmds :
- echo "Updating changelog:"
- set +e
- git changelog -t "v$VERSION"
- set -e
- echo "\nCommitting version.go and changelog update"
- git add util/version.go CHANGELOG.md && git commit -m "update changelog, bump version to $VERSION"
- echo "\nTagging release"
- git tag -m "v$VERSION release" "v$VERSION"
- echo "\nPushing to repository"
- git push origin develop "v$VERSION"
- echo "\nCreating draft release v$VERSION"
- github-release release --draft -u ansible-semaphore -r semaphore -t "v$VERSION" -d "## Special thanks to\n\n## Installation\n\nFollow [wiki/Installation](https://github.com/ansible-semaphore/semaphore/wiki/Installation)\n\n## Changelog"
- task : build
- echo "Uploading files.."
- find . -name "bin/semaphore_*" -exec sh -c 'gpg --armor --detach-sig "$1"' _ {} \;
- VERSION=$2 find . -name "bin/semaphore_*" -exec sh -c 'github-release upload -u ansible-semaphore -r semaphore -t "v$VERSION" -n "${1/.\/}" -f "$1"' _ {} \;
- echo "Done"
- rm -rf bin