diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..2167568 --- /dev/null +++ b/.circleci/config.yml @@ -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} ./ diff --git a/Readme.md b/Readme.md index 7843726..d2b7894 100644 --- a/Readme.md +++ b/Readme.md @@ -4,7 +4,16 @@ Inspired by the book [Deep Work](http://calnewport.com/books/deep-work/) from Ca Currently only working with Mac OS X, more variety to come soon. -## Set-Up +## Installation + +Simply grab the desired version from the Github Release page and place it in your $PATH, e.g. + +```shell +curl -L https://github.com/SimonTheLeg/deepwork/releases/download/v0.1.0/deepwork-darwin-64 -o /usr/local/bin/deepwork +``` + + +## Configuration create a config file under ~/.deepwork/config.json and add the names of all communication applications. An example config can be found in [example-config.json](example-config.json). By default Mail and Calendar will be added. diff --git a/main.go b/main.go index da28383..ddbaf3c 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,8 @@ import ( var configLocation string +var version = "dev-build" + type config struct { AffectedApps []string `json:"affectedApps"` } @@ -41,6 +43,10 @@ func main() { var action func(name string) error action = determineAction(desAction) + if action == nil { + os.Exit(0) + } + // Execute action for _, app := range config.AffectedApps { err := action(app) @@ -56,7 +62,11 @@ func determineAction(desAction string) func(name string) error { return CloseApp case "off": return OpenApp + case "version": + fmt.Println(version) + return nil default: + fmt.Println("Usage: deepwork [on,off,version]") return nil } }