-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Circle-CI config * Update config.yml to be Circle CI 2.0 compatible * Add support for store_test_results * Change test output format to junit, so circle ci can automatically recognize it * Add ability to list deepwork version * Add ability to persist go binary for release step * Add github release step * Add info about installation in Readme * Use ldflags for app version instead of hardcoding it in main.go * Only run publish-github-release on master branch
- Loading branch information
1 parent
94f8ff6
commit 249924c
Showing
3 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
version: 2 | ||
|
||
workflows: | ||
version: 2 | ||
main: | ||
jobs: | ||
- build | ||
- publish-github-release: | ||
requires: | ||
- build | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
|
||
jobs: | ||
|
||
build: | ||
docker: | ||
- image: circleci/golang:1.10 | ||
working_directory: /go/src/github.com/simontheleg/deepwork | ||
environment: | ||
TEST_RES_DIR: /tmp/test-results | ||
ARTIFACTS_DIR: /tmp/artifacts | ||
APP_VERSION: v0.1.1 | ||
steps: | ||
- checkout | ||
- run: | ||
name: Create required dirs | ||
command: | | ||
mkdir ${TEST_RES_DIR} | ||
mkdir ${ARTIFACTS_DIR} | ||
# This dependency is required to convert 'go test' results to junit ones for Circle CI to automatically recognize them | ||
- run: | ||
name: Fetch go-junit-report | ||
command: go get github.com/jstemmer/go-junit-report | ||
- run: | ||
name: Resolve dependencies with go-get | ||
command: go get -v -t -d ./... | ||
- run: | ||
name: Run go test | ||
command: | | ||
go test -v -cover ./... | tee ${TEST_RES_DIR}/go-test.out | ||
go-junit-report <${TEST_RES_DIR}/go-test.out > ${TEST_RES_DIR}/go-test-report.xml | ||
- store_test_results: | ||
path: /tmp/test-results | ||
- run: | ||
name: Build app | ||
command: | | ||
env GOOS=darwin GOARCH=amd64 go build -o ${ARTIFACTS_DIR}/deepwork-darwin-64 -ldflags "-X main.version=${APP_VERSION}" | ||
env GOOS=linux GOARCH=amd64 go build -o ${ARTIFACTS_DIR}/deepwork-linux-64 -ldflags "-X main.version=${APP_VERSION}" | ||
- persist_to_workspace: | ||
root: /tmp/artifacts | ||
paths: | ||
- ./* | ||
|
||
publish-github-release: | ||
docker: | ||
- image: simontheleg/github-go-releaser | ||
steps: | ||
- attach_workspace: | ||
at: ./ | ||
- run: | ||
name: Publish Release on Github | ||
command: | | ||
VERSION=$(./deepwork-linux-64 version) | ||
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters