Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cede079

Browse files
authored
Merge pull request #3 from Aristat/circleci-project-setup
Add .circleci/config.yml
2 parents 1769f3d + 0be2e84 commit cede079

File tree

3 files changed

+77
-13
lines changed

3 files changed

+77
-13
lines changed

‎.circleci/config.yml‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
version: 2.1
2+
jobs:
3+
test:
4+
docker:
5+
- image: circleci/golang:1.14
6+
working_directory: ~/golang-example-app
7+
steps:
8+
- checkout
9+
- run:
10+
name: "Setup APP_WD"
11+
command: echo 'export APP_WD="$(cd ${CIRCLE_WORKING_DIRECTORY}; pwd)/resources"' >> $BASH_ENV
12+
- run:
13+
name: Fetch dependencies
14+
command: go mod download
15+
- run:
16+
name: Test
17+
command: go test ./...
18+
build:
19+
docker:
20+
- image: circleci/golang:1.14
21+
working_directory: ~/golang-example-app
22+
steps:
23+
- checkout
24+
- run:
25+
name: Fetch dependencies
26+
command: go mod download
27+
- run:
28+
name: Building
29+
command: |
30+
VERSION=${CIRCLE_TAG}
31+
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.Version=${VERSION}" -o bin/app-${VERSION}-linux-amd64 main.go
32+
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.Version=${VERSION}" -o bin/app-${VERSION}-darwin-amd64 main.go
33+
- persist_to_workspace:
34+
root: .
35+
paths:
36+
- bin
37+
publish-github-release:
38+
docker:
39+
- image: cibuilds/github:0.13
40+
steps:
41+
- attach_workspace:
42+
at: ~/golang-example-app
43+
- run:
44+
name: "Publish Release on GitHub"
45+
command: |
46+
VERSION=${CIRCLE_TAG}
47+
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ~/golang-example-app/bin
48+
workflows:
49+
version: 2
50+
main:
51+
jobs:
52+
- test
53+
release:
54+
jobs:
55+
- build:
56+
filters:
57+
branches:
58+
ignore: /.*/
59+
tags:
60+
only: /^v\d+\.\d+\.\d+.*/
61+
- publish-github-release:
62+
requires:
63+
- build
64+
filters:
65+
branches:
66+
ignore: /.*/
67+
tags:
68+
only: /^v\d+\.\d+\.\d+.*/

‎Makefile‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ define build_resources
1818
endef
1919

2020
install: init ## install cli tools
21-
export GO111MODULE=off ;\
22-
go get -v github.com/rubenv/sql-migrate/... ;\
21+
go get -v github.com/rubenv/sql-migrate/... ;\
2322
go get -u github.com/google/wire/cmd/wire ;\
2423
go get -u github.com/vektah/dataloaden ;
2524

@@ -30,10 +29,8 @@ init: ## init packages
3029
start: ## start daemon on development mode
3130
./artifacts/bin daemon -c ./artifacts/configs/development.yaml -d
3231

33-
vendor: ## generate vendor
34-
rm -rf $(GO_DIR)/vendor ;\
35-
GO111MODULE=on \
36-
go mod vendor
32+
dependencies: ## generate dependencies
33+
go mod download
3734

3835
gqlgen-generate: ## generate graphql server
3936
go run github.com/99designs/gqlgen
@@ -43,17 +40,16 @@ prototool-generate: ## generate proto file
4340

4441
build: init ## build binary file
4542
$(call build_resources) ;\
46-
GO111MODULE=on GOOS=${GOOS} CGO_ENABLED=${CGO_ENABLED} GOARCH=${GOARCH} \
47-
go build -mod vendor -ldflags "-X $(GO_PKG)/cmd/version.appVersion=$(TAG)-$$(date -u +%Y%m%d%H%M)" -o "$(GO_DIR)/artifacts/bin" main.go
43+
GOOS=${GOOS} CGO_ENABLED=${CGO_ENABLED} GOARCH=${GOARCH} \
44+
go build -ldflags "-X $(GO_PKG)/cmd/version.appVersion=$(TAG)-$$(date -u +%Y%m%d%H%M)" -o "$(GO_DIR)/artifacts/bin" main.go
4845

4946
docker-image: ## build docker image
5047
REMOVE_CONTAINERS=${REMOVE_CONTAINERS} DOCKER_IMAGE=${DOCKER_IMAGE} ./scripts/remove_docker_containers.sh
5148
docker rmi ${DOCKER_IMAGE}:${TAG} -f || true ;\
5249
docker build --cache-from ${DOCKER_IMAGE}:${CACHE_TAG} -f "${GO_DIR}/docker/app/Dockerfile" -t ${DOCKER_IMAGE}:${TAG} ${GO_DIR}
5350

5451
test: ## test application with race
55-
GO111MODULE=on \
56-
go test -mod vendor -race -v ./...
52+
go test -v ./...
5753

5854
coverage: ## test coverage
5955
go test -coverprofile=coverage.out ./...
@@ -65,7 +61,7 @@ createdb: ## create database
6561
dropdb: ## drop database
6662
dropdb $(DATABASE_URL)
6763

68-
.PHONY: install init vendor gqlgen-generate prototool-generate
64+
.PHONY: install init dependencies gqlgen-generate prototool-generate
6965

7066
help:
7167
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "033円[36m%-30s033円[0m %s\n", $1,ドル $2ドル}'

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ Sql migrations
8888
sql-migrate up
8989
```
9090

91-
Install Golang packages to vendor
91+
Install Golang dependencies
9292

9393
```$xslt
94-
make vendor
94+
make dependencies
9595
```
9696

9797
Generate artifacts(binary files and configs)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /