1- # Golang CircleCI 2.0 configuration file
2- #
3- # Check https://circleci.com/docs/2.0/language-go/ for more details
4- version : 2
1+ version : 2.1
52jobs :
3+ test :
4+ docker :
5+ - image : circleci/golang:1.14
6+ working_directory : ~/golang-example-app
7+ steps :
8+ - checkout
9+ - run :
10+ name : Fetch dependencies
11+ command : go mod download
12+ - run :
13+ name : Test
14+ command : |
15+ APP_WD=~/golang-example-app/resources
16+ go test ./...
617 build :
718 docker :
8- # specify the version
9- - image : circleci/golang:1.9
10-
11- # Specify service dependencies here if necessary
12- # CircleCI maintains a library of pre-built images
13- # documented at https://circleci.com/docs/2.0/circleci-images/
14- # - image: circleci/postgres:9.4
15-
16- # ### TEMPLATE_NOTE: go expects specific checkout path representing url
17- # ### expecting it in the form of
18- # ### /go/src/github.com/circleci/go-tool
19- # ### /go/src/bitbucket.org/circleci/go-tool
20- working_directory : /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}
19+ - image : circleci/golang:1.14
20+ working_directory : ~/golang-example-app
2121 steps :
2222 - checkout
23-
24- # specify any bash command here prefixed with `run: `
25- - run : go get -v -t -d ./...
26- - run : go test -v ./...
23+ - run :
24+ name : Fetch dependencies
25+ command : go mod download
26+ - run :
27+ name : Building
28+ command : |
29+ VERSION=${CIRCLE_TAG}
30+ GOOS=linux GOARCH=amd64 go build -ldflags "-X main.Version=${VERSION}" -o bin/app-${VERSION}-linux-amd64 main.go
31+ GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.Version=${VERSION}" -o bin/app-${VERSION}-darwin-amd64 main.go
32+ - persist_to_workspace :
33+ root : .
34+ paths :
35+ - bin
36+ publish-github-release :
37+ docker :
38+ - image : cibuilds/github:0.13
39+ steps :
40+ - attach_workspace :
41+ at : ~/golang-example-app
42+ - run :
43+ name : " Publish Release on GitHub"
44+ command : |
45+ VERSION=${CIRCLE_TAG}
46+ ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ~/golang-example-app/bin
47+ workflows :
48+ version : 2
49+ main :
50+ jobs :
51+ - test
52+ release :
53+ jobs :
54+ - build :
55+ filters :
56+ branches :
57+ ignore : /.*/
58+ tags :
59+ only : /^v\d+\.\d+\.\d+.*/
60+ - publish-github-release :
61+ requires :
62+ - build
63+ filters :
64+ branches :
65+ ignore : /.*/
66+ tags :
67+ only : /^v\d+\.\d+\.\d+.*/
0 commit comments