Skip to content

Commit

Permalink
Setup Circle CI for publish GitHub Release (#24)
Browse files Browse the repository at this point in the history
Issue: #22
  • Loading branch information
felipemfp authored Oct 30, 2018
1 parent 73aeca7 commit 59d764b
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 53 deletions.
53 changes: 53 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: 2

jobs:
build:
docker:
- image: circleci/golang:1.10.3
working_directory: /go/src/github.com/felipemfp/sinonimos
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "src/sinonimos/Gopkg.lock" }}

- run: go get -u golang.org/x/lint/golint
- run: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- run: make dep-ensure
- run: make lint
- run: make install

- save_cache:
key: dependency-cache-{{ checksum "src/sinonimos/Gopkg.lock" }}
paths:
- src/sinonimos/vendor

- persist_to_workspace:
root: bin
paths:
- sinonimos

release:
docker:
- image: cibuilds/github:0.10
working_directory: /go/src/github.com/felipemfp/sinonimos
steps:
- attach_workspace:
at: ./bin
- run: ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${CIRCLE_TAG} ./bin/

workflows:
version: 2
build_and_release:
jobs:
- build:
filters: # required since `release` has tag filters AND requires `build`
tags:
only: /.*/
- release:
requires:
- build
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ DEP=cd $(PROJECT_PATH) && GOPATH=$(GOPATH) dep

.DEFAULT_GOAL: install

.PHONY: dep-ensure dep-add dep-status install run
.PHONY: dep-ensure dep-update dep-add dep-status install run

dep-ensure:
@$(DEP) ensure -v
Expand All @@ -34,3 +34,9 @@ install: dep-ensure

run:
@GOPATH=$(GOPATH) $(GOCMD) run $(PROJECT_PATH)/main.go $(WORD)

vet:
@GOPATH=$(GOPATH) $(GOCMD) vet ./src/$(PROJECT)

lint: vet
@GOPATH=$(GOPATH) golint -set_exit_status ./src/$(PROJECT)
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# 🇧🇷 sinonimos
# 🇧🇷 sinonimos [![CircleCI](https://circleci.com/gh/felipemfp/sinonimos-cli.svg?style=shield)](https://circleci.com/gh/felipemfp/sinonimos-cli)

Find synonyms without leaving your terminal

![Alt Text](sinonimos-peek.gif)



## Installing

Run this command to download the latest version of `sinonimos`:
Expand Down Expand Up @@ -34,8 +32,9 @@ These instructions will get you a copy of the project up and running on your loc

What things you need to start hacking:

* [go](https://golang.org/doc/install)
* [golang/dep](https://github.com/golang/dep/blob/master/docs/installation.md)
- [go](https://golang.org/doc/install)
- [golang/dep](https://github.com/golang/dep/blob/master/docs/installation.md)
- [golang/lint](https://github.com/golang/lint#installation)

### Getting started

Expand All @@ -55,28 +54,29 @@ make dep-ensure
Now you're ready to go.

> See `Makefile` for useful development scripts, for example:
>
> ```
> make run WORD=camisa
> ```
> ```
>
> It'll run the project and try to find synonyms for "camisa".

## Built With

* [mow.cli](https://github.com/jawher/mow.cli)
* [scrape](https://github.com/yhat/scrape)
- [mow.cli](https://github.com/jawher/mow.cli)
- [scrape](https://github.com/yhat/scrape)

## Contributing

Please feel free for submitting pull requests to us.

## Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/felipemfp/sinonimos-cli/tags).
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/felipemfp/sinonimos-cli/tags).

## Authors

* **Felipe Pontes** - *Initial work* - [felipemfp](https://github.com/felipemfp)
- **Felipe Pontes** - _Initial work_ - [felipemfp](https://github.com/felipemfp)

See also the list of [contributors](https://github.com/felipemfp/sinonimos-cli/contributors) who participated in this project.

Expand Down
14 changes: 0 additions & 14 deletions src/sinonimos/go.mod

This file was deleted.

19 changes: 0 additions & 19 deletions src/sinonimos/go.sum

This file was deleted.

21 changes: 13 additions & 8 deletions src/sinonimos/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/briandowns/spinner"
. "github.com/logrusorgru/aurora"
"github.com/logrusorgru/aurora"

"github.com/yhat/scrape"
"golang.org/x/net/html"
Expand Down Expand Up @@ -56,7 +56,7 @@ func find(word string) error {
s.Stop()

if resp.StatusCode == http.StatusNotFound {
fmt.Printf(" %s\n", Red("Desculpa, mas não encontramos nenhum sinônimo"))
fmt.Printf(" %s\n", aurora.Red("Desculpa, mas não encontramos nenhum sinônimo"))
os.Exit(1)
}

Expand All @@ -67,15 +67,14 @@ func find(word string) error {
}

meaningSections := scrape.FindAll(root, scrape.ByClass("s-wrapper"))
for _, meaningSection := range meaningSections {
for j, meaningSection := range meaningSections {
if meaning, ok := scrape.Find(meaningSection, scrape.ByClass("sentido")); ok {
fmt.Printf("\n> %s\n", scrape.Text(meaning))
fmt.Printf("\n> %s\n", aurora.Colorize(scrape.Text(meaning), getColors(j)).Bold())

synonyms := scrape.FindAll(meaningSection, scrape.ByClass("sinonimo"))
fmt.Print(" ")
for i, synonym := range synonyms {
output := fmt.Sprintf("%s", scrape.Text(synonym))
fmt.Print(Colorize(output, getColors(i)))
fmt.Print(scrape.Text(synonym))
if i == (len(synonyms) - 1) {
fmt.Print("\n")
} else {
Expand All @@ -88,8 +87,14 @@ func find(word string) error {
return nil
}

func getColors(index int) Color {
colors := [6]Color{RedFg, GreenFg, BrownFg, BlueFg, MagentaFg, CyanFg}
func getColors(index int) aurora.Color {
colors := []aurora.Color{
aurora.GreenFg,
aurora.BrownFg,
aurora.BlueFg,
aurora.MagentaFg,
aurora.CyanFg,
}
if index != 0 {
index = index % len(colors)
}
Expand Down

0 comments on commit 59d764b

Please sign in to comment.