File tree Expand file tree Collapse file tree 5 files changed +47
-32
lines changed
Expand file tree Collapse file tree 5 files changed +47
-32
lines changed Original file line number Diff line number Diff line change 88_obj
99_test
1010vendor
11+ dist
1112
1213# Architecture specific extensions/prefixes
1314* . [568vq ]
Original file line number Diff line number Diff line change 1+ builds :
2+ - main : ./cmd/gosec/
3+ binary : gosec
4+ goos :
5+ - darwin
6+ - linux
7+ - windows
8+ goarch :
9+ - amd64
10+ ldflags : -X main.Version={{.Version}} -X main.GitTag={{.Tag}} -X main.BuildDate={{.Date}}
11+ env :
12+ - CGO_ENABLED=0
13+
14+ archive :
15+ files :
16+ - README.md
17+ - LICENSE.txt
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ FROM golang:1.9.4-alpine3.7
22
33ENV BIN=gosec
44
5- COPY build/*-linux-amd64 /go/bin/$BIN
5+ COPY dist/linux_amd64/$BIN /go/bin/$BIN
66COPY docker-entrypoint.sh /usr/local/bin
77
88ENTRYPOINT ["docker-entrypoint.sh" ]
Original file line number Diff line number Diff line change 11GIT_TAG? = $(shell git describe --always --tags)
2- BUILD_DATE = $(shell date +% Y-% m-% d)
32BIN = gosec
4- BUILD_CMD = go build -ldflags "-X main.Version=${VERSION} -X main.GitTag=${GIT_TAG} -X main.BuildDate=${BUILD_DATE}" -o build/$(BIN ) -$(VERSION ) -$${GOOS}-$${GOARCH} ./cmd/gosec/ &
53FMT_CMD = $(gofmt -s -l -w $(find . -type f -name '*.go' -not -path './vendor/*' ) | tee /dev/stderr )
64IMAGE_REPO = docker.io
75
86default :
97 $(MAKE ) bootstrap
108 $(MAKE ) build
119
10+ bootstrap :
11+ dep ensure
12+
1213test : bootstrap
1314 test -z ' $(FMT_CMD)'
1415 go vet $(go list ./... | grep -v /vendor/ )
1516 golint -set_exit_status $(shell go list ./... | grep -v vendor)
1617 gosec ./...
1718 ginkgo -r -v
18- bootstrap :
19- dep ensure
19+
2020build :
2121 go build -o $(BIN ) ./cmd/gosec/
22+
2223clean :
23- rm -rf build vendor
24+ rm -rf build vendor dist
2425 rm -f release image bootstrap $(BIN )
26+
2527release : bootstrap
26- ifndef VERSION
27- $(error VERSION flag is not set. Run 'make release VERSION=<YOUR VERSION>'.)
28- endif
29- @echo "Running build command..."
30- bash -c '\
31- export GOOS=linux; export GOARCH=amd64; export CGO_ENABLED=0; $(BUILD_CMD) \
32- wait \
33- '
34- touch release
28+ @echo " Releasing the gosec binary..."
29+ goreleaser release
3530
3631image : release
3732 @echo " Building the Docker image..."
38- docker build -t $(IMAGE_REPO ) /$(BIN ) :$(VERSION ) .
39- docker tag $(IMAGE_REPO ) /$(BIN ) :$(VERSION ) $(IMAGE_REPO ) /$(BIN ) :latest
33+ docker build -t $(IMAGE_REPO ) /$(BIN ) :$(GIT_TAG ) .
34+ docker tag $(IMAGE_REPO ) /$(BIN ) :$(GIT_TAG ) $(IMAGE_REPO ) /$(BIN ) :latest
4035 touch image
4136
4237image-push : image
4338 @echo " Pushing the Docker image..."
44- docker push $(IMAGE_REPO ) /$(BIN ) :$(VERSION )
39+
40+ docker push $(IMAGE_REPO ) /$(BIN ) :$(GIT_TAG )
4541 docker push $(IMAGE_REPO ) /$(BIN ) :latest
4642
47- .PHONY : test build clean image-push
43+ .PHONY : test build clean release image image-push
4844
Original file line number Diff line number Diff line change @@ -143,34 +143,35 @@ make test
143143
144144#### Release Build
145145
146- gosec can be released as follows:
146+ Make sure you have installed the [ goreleaser] ( https://github.com/goreleaser/goreleaser ) tool and then you can release gosec as follows:
147+ git tag 1.0.0
148+ export GITHUB_TOKEN=<YOUR GITHUB TOKEN >
149+ make release
147150
148- ``` bash
149- make release VERSION=2.0.0
150- ```
151-
152- The released version of the tool is available in the ` build ` folder. The build information should be displayed in the usage text.
151+ The released version of the tool is available in the ` dist ` folder. The build information should be displayed in the usage text.
153152
154153```
155- ./build/gosec-2.0.0-linux-amd64 -h
156-
154+ ./dist/darwin_amd64/gosec -h
157155gosec - Golang security checker
158156
159157gosec analyzes Go source code to look for common programming mistakes that
160158can lead to security problems.
161159
162- VERSION: 2.0.0
163- GIT TAG: 96489ff
164- BUILD DATE: 2018-02-21
165-
160+ VERSION: 1.0.0
161+ GIT TAG: 1.0.0
162+ BUILD DATE: 2018-04-27T12:41:38Z
166163```
167164
165+ Note that all released archives are also uploaded to GitHub.
166+
168167#### Docker image
169168
170169You can execute a release and build the docker image as follows:
171170
172171```
173- make image VERSION=2.0.0
172+ git tag <VERSION>
173+ export GITHUB_TOKEN=<Your GitHub token>
174+ make image
174175```
175176
176177Now you can run the gosec tool in a container against your local workspace:
You can’t perform that action at this time.
0 commit comments