Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 2edadbd

Browse files
Automate releases (#467)
* Automate releases * Trim upload_artifacts params * Update README.md Co-authored-by: noelia-lencina <[email protected]> Co-authored-by: noelia-lencina <[email protected]>
1 parent 1f97e2f commit 2edadbd

File tree

9 files changed

+252
-100
lines changed

9 files changed

+252
-100
lines changed

.circleci/config.yml

Lines changed: 78 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,136 @@
11
version: 2
2+
3+
linux_image: &linux_image
4+
docker:
5+
- image: circleci/golang:1.15
6+
working_directory: /go/src/github.com/codeclimate/test-reporter
7+
setup_remote_docker:
8+
docker_layer_caching: true
9+
10+
macos_image: &macos_image
11+
macos:
12+
xcode: "11.3.0"
13+
14+
setup_macos_env: &setup_macos_env
15+
216
jobs:
317
test_linux:
4-
docker:
5-
- image: circleci/golang:1.15
6-
working_directory: /go/src/github.com/codeclimate/test-reporter
7-
setup_remote_docker:
8-
docker_layer_caching: true
18+
<<: *linux_image
919
steps:
1020
- checkout
1121
- run: make test
1222

13-
release_linux:
14-
docker:
15-
- image: circleci/golang:1.15
16-
working_directory: /go/src/github.com/codeclimate/test-reporter
17-
setup_remote_docker:
18-
docker_layer_caching: true
23+
release_head_linux:
24+
<<: *linux_image
1925
steps:
2026
- checkout
2127
- run: sudo apt-get install awscli
2228
- run: make build-linux-all VERSION=head
2329
- run: make publish-head
2430

31+
release_linux:
32+
<<: *linux_image
33+
steps:
34+
- checkout
35+
- run: sudo apt-get install awscli
36+
- run: make build-linux-all
37+
- run: make build-linux-all VERSION=latest
38+
- run: make publish-latest
39+
- run: make publish-version
40+
2541
test_macos:
26-
macos:
27-
xcode: "11.3.0"
42+
<<: *macos_image
2843
steps:
2944
- checkout
3045
- run:
31-
name: Install go
32-
command: |
33-
curl -O https://dl.google.com/go/go1.15.darwin-amd64.tar.gz
34-
tar -xzf go1.15.darwin-amd64.tar.gz
35-
echo 'export PATH=$PATH:$PWD/go/bin' >> "$BASH_ENV"
36-
- run:
37-
name: Setup gopath
38-
command: |
39-
mkdir -p ~/gopath/src/github.com/codeclimate/test-reporter
40-
echo 'export GOPATH=$HOME/gopath' >> "$BASH_ENV"
41-
. "$BASH_ENV"
42-
cd $GOPATH/src/github.com/codeclimate/test-reporter
43-
cp -r ~/project/ $GOPATH/src/github.com/codeclimate/test-reporter/
46+
command: sh .circleci/xcode_install_go
4447
- run:
4548
name: Run tests
4649
command: |
4750
cd $GOPATH/src/github.com/codeclimate/test-reporter
4851
make test
4952
50-
release_macos:
51-
macos:
52-
xcode: "11.3.0"
53+
release_head_macos:
54+
<<: *macos_image
5355
steps:
5456
- checkout
5557
- run: pip install awscli
5658
- run:
57-
name: Install go
58-
command: |
59-
curl -O https://dl.google.com/go/go1.15.darwin-amd64.tar.gz
60-
tar -xzf go1.15.darwin-amd64.tar.gz
61-
echo 'export PATH=$PATH:$PWD/go/bin' >> "$BASH_ENV"
62-
- run:
63-
name: Setup gopath
64-
command: |
65-
mkdir -p ~/gopath/src/github.com/codeclimate/test-reporter
66-
echo 'export GOPATH=$HOME/gopath' >> "$BASH_ENV"
67-
. "$BASH_ENV"
68-
cd $GOPATH/src/github.com/codeclimate/test-reporter
69-
cp -r ~/project/ $GOPATH/src/github.com/codeclimate/test-reporter/
59+
command: sh .circleci/xcode_install_go
7060
- run:
71-
name: Build
61+
name: Build & Upload artifacts to S3
7262
command: |
7363
cd $GOPATH/src/github.com/codeclimate/test-reporter
7464
make build-darwin VERSION=head
65+
make publish-head
66+
67+
release_macos:
68+
<<: *macos_image
69+
steps:
70+
- checkout
71+
- run: pip install awscli
72+
- run:
73+
command: sh .circleci/xcode_install_go
7574
- run:
76-
name: Publish
75+
name: Build & Upload artifacts to S3
7776
command: |
7877
cd $GOPATH/src/github.com/codeclimate/test-reporter
79-
make publish-head
78+
make build-darwin
79+
make build-darwin VERSION=latest
80+
make publish-latest
81+
make publish-version
82+
83+
github_release:
84+
<<: *linux_image
85+
steps:
86+
- run: sudo apt install hub
87+
- checkout
88+
- run:
89+
name: Create new GH release
90+
command: sh release-scripts/gh_release
8091

8192
workflows:
8293
version: 2
8394
build_deploy:
8495
jobs:
8596
- test_linux
8697
- test_macos
87-
- release_linux:
98+
- release_head_linux:
8899
requires:
89100
- test_linux
90101
- test_macos
91102
filters:
92103
branches:
93104
only:
94105
- master
95-
- release_macos:
106+
- release_head_macos:
96107
requires:
97108
- test_linux
98109
- test_macos
99110
filters:
100111
branches:
101112
only:
102113
- master
114+
- release_linux:
115+
requires:
116+
- test_linux
117+
- test_macos
118+
filters:
119+
branches:
120+
only: /^v\d+\.\d+\.\d+$/
121+
- release_macos:
122+
requires:
123+
- test_linux
124+
- test_macos
125+
filters:
126+
branches:
127+
only: /^v\d+\.\d+\.\d+$/
128+
- github_release:
129+
requires:
130+
- release_linux
131+
filters:
132+
branches:
133+
only: /^v\d+\.\d+\.\d+$/
103134

104135
notify:
105136
webhooks:

.circleci/xcode_install_go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
#
3+
# Installs Golang in an mac os environment
4+
#
5+
###
6+
set -e
7+
set -o nounset
8+
set -o errexit
9+
set -o pipefail
10+
11+
PROJECT_RELATIVE_PATH=src/github.com/codeclimate/test-reporter
12+
13+
# Install go
14+
curl -O https://dl.google.com/go/go1.15.darwin-amd64.tar.gz
15+
tar -xzf go1.15.darwin-amd64.tar.gz
16+
echo 'export PATH=$PATH:$PWD/go/bin' >> "$BASH_ENV"
17+
18+
# Set go path
19+
mkdir -p ~/gopath/${PROJECT_RELATIVE_PATH}
20+
echo 'export GOPATH=$HOME/gopath' >> "$BASH_ENV"
21+
. "$BASH_ENV"
22+
cd $GOPATH/${PROJECT_RELATIVE_PATH}
23+
cp -r ~/project/ $GOPATH/${PROJECT_RELATIVE_PATH}

Makefile

Lines changed: 39 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,20 @@ MAN_FILES = $(wildcard man/*.md)
1010
MAN_PAGES = $(patsubst man/%.md,man/%,$(MAN_FILES))
1111

1212
PROJECT = github.com/codeclimate/test-reporter
13-
VERSION ?= 0.10.0
13+
VERSION ?= $(shell cat VERSIONING/VERSION)
1414
BUILD_VERSION = $(shell git log -1 --pretty=format:'%H')
1515
BUILD_TIME = $(shell date +%FT%T%z)
1616
LDFLAGS = -ldflags "-X $(PROJECT)/version.Version=${VERSION} -X $(PROJECT)/version.BuildVersion=${BUILD_VERSION} -X $(PROJECT)/version.BuildTime=${BUILD_TIME}"
1717

18+
define upload_artifacts
19+
$(AWS) s3 cp \
20+
--acl public-read \
21+
--recursive \
22+
--exclude "*" \
23+
--include "test-reporter-$(1)-*" \
24+
artifacts/bin/ s3://codeclimate/test-reporter/;
25+
endef
26+
1827
man/%: man/%.md
1928
$(PANDOC) -s -t man $< -o $@
2029

@@ -33,62 +42,63 @@ build:
3342
go build -v ${LDFLAGS} -tags ${BUILD_TAGS} -o $(PREFIX)bin/test-reporter$(BINARY_SUFFIX); \
3443
fi
3544

36-
build-linux-all:
37-
$(MAKE) build-linux
38-
$(MAKE) build-linux-cgo
3945

4046
build-linux:
4147
$(MAKE) build \
4248
PREFIX=artifacts/ \
4349
BINARY_SUFFIX=-$(VERSION)-linux-amd64 \
4450
CGO_ENABLED=0
4551

46-
build-docker-linux:
47-
$(MAKE) build-docker GOOS=linux GOARCH=amd64 CGO_ENABLED=0
48-
49-
build-docker-linux-cgo:
50-
$(MAKE) build-docker GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \
51-
BUILD_TAGS="netcgo" BINARY_SUFFIX=-$(VERSION)-netcgo-linux-amd64
52-
5352
build-linux-cgo:
5453
$(MAKE) build \
5554
PREFIX=artifacts/ \
5655
BINARY_SUFFIX=-$(VERSION)-netcgo-linux-amd64 \
5756
CGO_ENABLED=1 \
5857
BUILD_TAGS="netcgo"
5958

59+
build-linux-all:
60+
$(MAKE) build-linux
61+
$(MAKE) build-linux-cgo
62+
6063
build-darwin:
6164
$(MAKE) build \
6265
PREFIX=artifacts/ \
6366
BINARY_SUFFIX=-$(VERSION)-darwin-amd64
6467

65-
test-docker:
68+
build-docker: BINARY_SUFFIX ?= -$(VERSION)-$$GOOS-$$GOARCH
69+
build-docker:
6670
$(DOCKER_RUN) \
71+
--env PREFIX=/artifacts/ \
72+
--env BINARY_SUFFIX=${BINARY_SUFFIX} \
73+
--env GOARCH \
74+
--env GOOS \
6775
--env GOPATH=/ \
76+
--env CGO_ENABLED \
77+
--volume "$(PWD)"/artifacts:/artifacts \
6878
--volume "$(PWD)":"/src/$(PROJECT)":ro \
6979
--workdir "/src/$(PROJECT)" \
70-
golang:1.8 make test
80+
golang:1.15 make build BUILD_TAGS=${BUILD_TAGS}
7181

72-
benchmark-docker:
82+
build-docker-linux:
83+
$(MAKE) build-docker GOOS=linux GOARCH=amd64 CGO_ENABLED=0
84+
85+
build-docker-linux-cgo:
86+
$(MAKE) build-docker GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \
87+
BUILD_TAGS="netcgo" BINARY_SUFFIX=-$(VERSION)-netcgo-linux-amd64
88+
89+
test-docker:
7390
$(DOCKER_RUN) \
7491
--env GOPATH=/ \
7592
--volume "$(PWD)":"/src/$(PROJECT)":ro \
7693
--workdir "/src/$(PROJECT)" \
77-
golang:1.8 make benchmark
94+
golang:1.15 make test
7895

79-
build-docker: BINARY_SUFFIX ?= -$(VERSION)-$$GOOS-$$GOARCH
80-
build-docker:
96+
benchmark-docker:
8197
$(DOCKER_RUN) \
82-
--env PREFIX=/artifacts/ \
83-
--env BINARY_SUFFIX=${BINARY_SUFFIX} \
84-
--env GOARCH \
85-
--env GOOS \
8698
--env GOPATH=/ \
87-
--env CGO_ENABLED \
88-
--volume "$(PWD)"/artifacts:/artifacts \
8999
--volume "$(PWD)":"/src/$(PROJECT)":ro \
90100
--workdir "/src/$(PROJECT)" \
91-
golang:1.8 make build BUILD_TAGS=${BUILD_TAGS}
101+
golang:1.15 make benchmark
92102

93103
test-simplecov:
94104
docker build -f integration-tests/simplecov/Dockerfile .
@@ -115,44 +125,21 @@ test-excoveralls:
115125
docker build -f integration-tests/excoveralls/Dockerfile .
116126

117127
publish-head:
118-
$(AWS) s3 cp \
119-
--acl public-read \
120-
--recursive \
121-
--exclude "*" \
122-
--include "test-reporter-head-*" \
123-
artifacts/bin/ s3://codeclimate/test-reporter/
128+
$(call upload_artifacts,head)
124129

125130
publish-latest:
126-
$(AWS) s3 cp \
127-
--acl public-read \
128-
--recursive \
129-
--exclude "*" \
130-
--include "test-reporter-latest-*" \
131-
artifacts/bin/ s3://codeclimate/test-reporter/
131+
$(call upload_artifacts,latest)
132132

133133
publish-version:
134-
if [ "$(shell curl https://s3.amazonaws.com/codeclimate/test-reporter/test-reporter-$(VERSION)-linux-amd64 --output /dev/null --write-out %{http_code})" -eq 403 ]; then \
135-
$(AWS) s3 cp \
136-
--acl public-read \
137-
--recursive \
138-
--exclude "*" \
139-
--include "test-reporter-$(VERSION)-*" \
140-
artifacts/bin/ s3://codeclimate/test-reporter/; \
141-
else \
142-
echo "Version $(VERSION) already published"; \
143-
exit 1; \
144-
fi
145-
146-
tag:
147-
$(GIT_TAG) --message v$(VERSION) v$(VERSION)
148-
$(GIT_PUSH) origin refs/tags/v$(VERSION)
134+
$(call upload_artifacts,$(VERSION))
149135

150136
clean:
151137
sudo $(RM) -r ./artifacts
152138
$(RM) $(MAN_PAGES)
153139

140+
154141
# Must be run in a OS X machine. OS X binary is build natively.
155-
release:
142+
manual-release:
156143
$(MAKE) build-docker-linux
157144
$(MAKE) build-docker-linux-cgo
158145
$(MAKE) build-darwin
@@ -161,4 +148,3 @@ release:
161148
$(MAKE) build-darwin VERSION=latest
162149
$(MAKE) publish-version
163150
$(MAKE) publish-latest
164-
$(MAKE) tag

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ For installation instructions, check out our docs on [Configuring Test Coverage]
1313

1414
To sign up for Code Climate, head [here](https://codeclimate.com/quality/pricing/).
1515

16+
## Releasing a new version
17+
18+
Test reporter's new versions are released automatically when pushing to branches that match `vx.x.x`. The test reporter's current version is documented in [VERSIONING/VERSION](https://github.com/codeclimate/test-reporter/blob/master/VERSIONING/VERSION), following the [Semantic Versioning](https://semver.org/) convention.
19+
20+
There are two script helpers for creating a new release:
21+
- [release-scripts/prep-release](https://github.com/codeclimate/test-reporter/blob/master/release-scripts/prep-release) which will create a new pull request, patching the current version. If you need to create a new MINOR or MAJOR version creating a manual pull request is the way to go.
22+
- [release-scripts/release](https://github.com/codeclimate/test-reporter/blob/master/release-scripts/release) This script will create a new branch named `vx.x.x` that matches the version indicated in [VERSIONING/VERSION](https://github.com/codeclimate/test-reporter/blob/master/VERSIONING/VERSION), which should trigger the CI for creating a new release.
1623

1724
## Copyright
1825

VERSIONING/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.10.0

0 commit comments

Comments
 (0)