From d501b6ca7261fba765e3218c23d4273c31fd0ad0 Mon Sep 17 00:00:00 2001 From: Tom Whiston Date: Tue, 13 Mar 2018 20:57:55 +0000 Subject: [PATCH] add .goreleaser and associated ci changes ignore package-json.lock fix CPATH for forks testing in circle by pinning to project name --- .gitignore | 1 + .goreleaser.yml | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ Taskfile.yml | 41 +++++++++++------------------ circle.yml | 12 +++++++-- 4 files changed, 94 insertions(+), 28 deletions(-) create mode 100644 .goreleaser.yml diff --git a/.gitignore b/.gitignore index 8430502e..ba86eba2 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ bin/ util/version.go /vendor/ /coverage.out +/public/package-lock.json diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..d8e906b6 --- /dev/null +++ b/.goreleaser.yml @@ -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}}" diff --git a/Taskfile.yml b/Taskfile.yml index 307234ff..37ae17b4 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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/ diff --git a/circle.yml b/circle.yml index 1303bf5f..8031ed70 100644 --- a/circle.yml +++ b/circle.yml @@ -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 @@ -41,4 +42,11 @@ test: - task ci:artifacts 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 \ No newline at end of file + - 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 \ No newline at end of file