Skip to content

Commit 445d4f4

Browse files
authored
Add scripts to generate signed checksums for binaries (#475)
* First draft on generating checksum for linux builds * Add checksum and signing functions to Makefile * Add Download and Veryfying binaries section to README * Remove step for releasing latest versions from circleci * Delete unnecessary release scripts
1 parent f404261 commit 445d4f4

File tree

5 files changed

+87
-103
lines changed

5 files changed

+87
-103
lines changed

.circleci/config.yml

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ jobs:
2828
- run: make build-linux-all VERSION=head
2929
- run: make publish-head
3030

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-
4131
test_macos:
4232
<<: *macos_image
4333
steps:
@@ -64,31 +54,6 @@ jobs:
6454
make build-darwin VERSION=head
6555
make publish-head
6656
67-
release_macos:
68-
<<: *macos_image
69-
steps:
70-
- checkout
71-
- run: pip install awscli
72-
- run:
73-
command: sh .circleci/xcode_install_go
74-
- run:
75-
name: Build & Upload artifacts to S3
76-
command: |
77-
cd $GOPATH/src/github.com/codeclimate/test-reporter
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
91-
9257
workflows:
9358
version: 2
9459
build_deploy:
@@ -111,26 +76,6 @@ workflows:
11176
branches:
11277
only:
11378
- 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+$/
13479

13580
notify:
13681
webhooks:

Makefile

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
.PHONY: test-docker build-docker build-linux-cgo release test-excoveralls
22

33
AWS ?= $(shell which aws)
4+
SHA_SUM ?= $(shell which shasum)
5+
GPG ?= $(shell which gpg)
6+
TAR ?= $(shell which tar)
47
DOCKER_RUN ?= $(shell which docker) run --rm
5-
GIT_PUSH ?= $(shell which git) push
6-
GIT_TAG ?= $(shell which git) tag --sign
78
PANDOC ?= $(shell which pandoc)
89

910
MAN_FILES = $(wildcard man/*.md)
@@ -14,6 +15,7 @@ VERSION ?= $(shell cat VERSIONING/VERSION)
1415
BUILD_VERSION = $(shell git log -1 --pretty=format:'%H')
1516
BUILD_TIME = $(shell date +%FT%T%z)
1617
LDFLAGS = -ldflags "-X $(PROJECT)/version.Version=${VERSION} -X $(PROJECT)/version.BuildVersion=${BUILD_VERSION} -X $(PROJECT)/version.BuildTime=${BUILD_TIME}"
18+
ARTIFACTS_OUTPUT = artifacts.tar.gz
1719

1820
define upload_artifacts
1921
$(AWS) s3 cp \
@@ -24,6 +26,12 @@ define upload_artifacts
2426
artifacts/bin/ s3://codeclimate/test-reporter/;
2527
endef
2628

29+
define gen_signed_checksum
30+
cd artifacts/bin && \
31+
$(SHA_SUM) -a 256 test-reporter-$(VERSION)-$(1) > test-reporter-$(VERSION)-$(1).sha256 && \
32+
$(GPG) --local-user $(GPG_CODECLIMATE_FINGERPRINT) --output test-reporter-$(VERSION)-$(1).sha256.sig --detach-sig test-reporter-$(VERSION)-$(1).sha256
33+
endef
34+
2735
man/%: man/%.md
2836
$(PANDOC) -s -t man $< -o $@
2937

@@ -133,18 +141,36 @@ publish-latest:
133141
publish-version:
134142
$(call upload_artifacts,$(VERSION))
135143

144+
gen-linux-checksum:
145+
$(call gen_signed_checksum,linux-amd64)
146+
147+
gen-linux-cgo-checksum:
148+
$(call gen_signed_checksum,netcgo-linux-amd64)
149+
150+
gen-darwin-checksum:
151+
$(call gen_signed_checksum,darwin-amd64)
152+
136153
clean:
137154
sudo $(RM) -r ./artifacts
138155
$(RM) $(MAN_PAGES)
139156

157+
tag:
158+
$(TAR) -c -f ${ARTIFACTS_OUTPUT} ./artifacts/bin/test-reporter-${VERSION}-* && \
159+
hub release create -a ${ARTIFACTS_OUTPUT} -m "v${VERSION}" ${VERSION}
140160

141161
# Must be run in a OS X machine. OS X binary is build natively.
142162
manual-release:
143163
$(MAKE) build-docker-linux
144164
$(MAKE) build-docker-linux-cgo
145165
$(MAKE) build-darwin
166+
$(MAKE) gen-linux-checksum
167+
$(MAKE) gen-linux-cgo-checksum
168+
$(MAKE) gen-darwin-checksum
146169
$(MAKE) build-docker-linux VERSION=latest
147170
$(MAKE) build-docker-linux-cgo VERSION=latest
148171
$(MAKE) build-darwin VERSION=latest
172+
$(MAKE) gen-linux-checksum VERSION=latest
173+
$(MAKE) gen-linux-cgo-checksum VERSION=latest
174+
$(MAKE) gen-darwin-checksum VERSION=latest
149175
$(MAKE) publish-version
150176
$(MAKE) publish-latest

README.md

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,67 @@ 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
16+
# Versioning
17+
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.
1718

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+
# Binaries
1920

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.
21+
## Download
22+
The test reporter is distributed as a pre-built binary named cc-test-reporter. You can fetch the pre-built binary from the following URLs:
23+
24+
### Linux
25+
- [codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64](https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64)
26+
- [codeclimate.com/downloads/test-reporter/test-reporter-${VERSION}-linux-amd64](https://codeclimate.com/downloads/test-reporter/test-reporter-${VERSION}-linux-amd64)
27+
28+
29+
### Linux netcgo (recommended if you're using a VPN)
30+
- [codeclimate.com/downloads/test-reporter/test-reporter-latest-netcgo-linux-amd64](https://codeclimate.com/downloads/test-reporter/test-reporter-latest-netcgo-linux-amd64)
31+
- [codeclimate.com/downloads/test-reporter/test-reporter-${VERSION}-netcgo-linux-amd64](https://codeclimate.com/downloads/test-reporter/test-reporter-${VERSION}-netcgo-linux-amd64)
32+
33+
### OS X
34+
- [codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64](https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64)
35+
- [codeclimate.com/downloads/test-reporter/test-reporter-${VERSION}-darwin-amd64](https://codeclimate.com/downloads/test-reporter/test-reporter-${VERSION}-darwin-amd64)
36+
37+
38+
#### e.g
39+
>```console
40+
>$ curl -O https://codeclimate.com/downloads/test-reporter/test-reporter-0.10.1-darwin-amd64
41+
>```
42+
43+
## Verifying binaries
44+
45+
Along with the binaries you can download a file with a SHA 256 checksum for the given version from the link shown below, or you can attach it to your clipboard from the [docs page](https://docs.codeclimate.com/docs/configuring-test-coverage#locations-of-pre-built-binaries).
46+
47+
- [codeclimate.com/downloads/test-reporter/test-reporter-${VERSION}-darwin-amd64.sha256](https://codeclimate.com/downloads/test-reporter/test-reporter-${VERSION}-darwin-amd64.sha256)
48+
49+
To download the file containing the checksum using `curl`:
50+
#### e.g
51+
>```console
52+
>$ curl -O https://codeclimate.com/downloads/test-reporter/test-reporter-0.10.1-darwin-amd64.sha256
53+
>```
54+
55+
To check that a downloaded file matches the checksum, run it through `shasum` with a command such as:
56+
57+
```console
58+
$ grep test-reporter-${VERSION}-darwin-amd64 test-reporter-${VERSION}-darwin-amd64.sha256 | shasum -a 256 -c -
59+
```
60+
61+
The GPG detached signature of SHA checksums can be download analogously from the following url:
62+
63+
- [codeclimate.com/downloads/test-reporter/test-reporter-${VERSION}-darwin-amd64.sha256.sig](https://codeclimate.com/downloads/test-reporter/test-reporter-${VERSION}-darwin-amd64.sha256.sig)
64+
65+
You can use it with `gpg` to verify the integrity of your downloaded checksum. You will first need to import
66+
the GPG publick key. To import the key:
67+
68+
```console
69+
$ gpg --keyserver keys.openpgp.org --recv-keys 9BD9E2DD46DA965A537E5B0A5CBF320243B6FD85
70+
```
71+
72+
Then use the following command to verify the file's signature.
73+
74+
```console
75+
$ gpg --verify test-reporter-${VERSION}-darwin-amd64.sha256.sig test-reporter-${VERSION}-darwin-amd64.sha256
76+
```
2377

2478
## Copyright
2579

release-scripts/gh_release

Lines changed: 0 additions & 26 deletions
This file was deleted.

release-scripts/release

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)