add .goreleaser and associated ci changes

ignore package-json.lock
fix CPATH for forks testing in circle by pinning to project name
This commit is contained in:
Tom Whiston 2018-03-13 20:57:55 +00:00
parent 3a6173fad9
commit d501b6ca72
4 changed files with 94 additions and 28 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ bin/
util/version.go
/vendor/
/coverage.out
/public/package-lock.json

68
.goreleaser.yml Normal file
View File

@ -0,0 +1,68 @@
# Goreleaser configuration
# for building binaries and packages for distributions and releasing on github
dist: bin
git:
short_hash: true
builds:
- binary: semaphore
main: ./cli/main.go
goos:
- windows
- darwin
- linux
- freebsd
- openbsd
- netbsd
goarch:
- amd64
- 386
- arm
- arm64
ignore:
- goos: darwin
goarch: 386
hooks:
pre: task compile
archive:
format_overrides:
- goos: windows
format: zip
files:
- LICENSE
- CHANGELOG.md
#sign:
# artifacts: checksum
# Start the snapshot name with a numerical value
# so it does not need to be force installed
snapshot:
name_template: "{{.Timestamp}}-{{.Commit}}-SNAPSHOT"
nfpm:
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
vendor: Castaway Consulting LLC
homepage: https://github.com/ansible-semaphore/semaphore
description: Open Source alternative to Ansible Tower
license: MIT
formats:
- deb
- rpm
# Packages your package depends on.
dependencies:
- ansible
- git
# install binary in /usr/bin
bindir: /usr/bin
release:
# Do not auto publish release
draft: true
name_template: "{{.Tag}}"

View File

@ -42,8 +42,9 @@ tasks:
- go get -u github.com/golang/dep/cmd/dep
- go get github.com/cespare/reflex
- go get -u github.com/gobuffalo/packr/...
- go get github.com/mitchellh/gox
- go get -u github.com/haya14busa/goverage
# needs go 1.10+
- go get github.com/goreleaser/goreleaser
compile:
@ -111,10 +112,9 @@ tasks:
- pug -w -P --doctype html $(find ./html/ -name "*.pug") &
build:
desc: Build a full set of release binaries
dir: cli
desc: Build a full set of release binaries and packages
cmds:
- gox -output="../bin/semaphore_{{"{{"}}.OS{{"}}"}}_{{"{{"}}.Arch{{"}}"}}" ./...
- task: release:test
build:local:
desc: Build a binary for the current architecture
@ -122,6 +122,16 @@ tasks:
cmds:
- go build -o ../bin/semaphore
release:test:
desc: creates a release without performing validations or publishing artifacts
cmds:
- goreleaser --snapshot --rm-dist
release:
desc: Build a full set of release binaries
cmds:
- goreleaser
test:
desc: Run go code tests
cmds:
@ -132,25 +142,4 @@ tasks:
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
- rsync -a bin/ $CIRCLE_ARTIFACTS/

View File

@ -1,12 +1,13 @@
machine:
environment:
CPATH: "${HOME}/.go_workspace/src/github.com/${CIRCLE_PROJECT_USERNAME}"
CPATH: "${HOME}/.go_workspace/src/github.com/ansible-semaphore"
node:
version: 8.2.0
dependencies:
pre:
- sudo apt-get install rpm
- rm -rf ${CPATH} && mkdir -p ${CPATH}
- ln -sfn ${HOME}/${CIRCLE_PROJECT_REPONAME} ${CPATH}
- sudo rm -rf /usr/local/go
@ -42,3 +43,10 @@ test:
post:
# We don't export the coverage secret to forks so we need this to always return successfully
- godacov -t "${CODACY_TOKEN}" -r ./coverage.out -c "${CIRCLE_SHA1}" || true
deployment:
tag:
tag: /v[0-9]+(\.[0-9]+)*(-.*)*/
owner: ansible-semaphore
commands:
- curl -sL https://git.io/goreleaser | bash