Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ci and cd (github release) #3

Merged
merged 24 commits into from
Aug 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .circleci/config.yml
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} ./
11 changes: 10 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (

var configLocation string

var version = "dev-build"

type config struct {
AffectedApps []string `json:"affectedApps"`
}
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
}
Expand Down