9esec-security-tooling/.circleci/config.yml

116 lines
4.0 KiB
YAML

# Golang CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
jobs:
build:
docker:
# specify the version
- image: circleci/golang:1.13
working_directory: /go/src/github.com/9elements/converged-security-suite
steps:
- checkout
- run: sudo apt install -y golint
# specify any bash command here prefixed with `run: `
- run: if [ "$(gofmt -l .)" != "" ]; then exit 1; fi
- run: golint -set_exit_status ./pkg/test
- run: golint -set_exit_status ./pkg/tools
- run: golint -set_exit_status ./pkg/hwapi
- run: golint -set_exit_status ./cmd/txt-suite
- run: go mod download
- run: go mod verify
- run: go build -o txt-suite cmd/txt-suite/*.go
- run: go test ./pkg/hwapi/
- run: go test ./pkg/tools/
- run: go test ./pkg/test/
- run: mkdir out
- run: git config user.email "circleci@circleci.com"
- run: git config user.name "CI"
- run: ./txt-suite -m > ./cmd/txt-suite/TESTPLAN.md
- run: git add ./cmd/txt-suite/TESTPLAN.md
- run: (git commit -m "Update testplan file" && git push --set-upstream origin ${CIRCLE_BRANCH}) || true
- run: cp txt-suite out/
- persist_to_workspace:
root: out
paths:
- txt-suite
create_deb_rpm:
docker:
# specify the version
- image: circleci/golang:1.13
working_directory: /go/src/github.com/9elements/converged-security-suite
steps:
- checkout
- attach_workspace:
at: /tmp/out
- run: go get github.com/goreleaser/nfpm/cmd/nfpm@v1.3.2
- run: go build github.com/goreleaser/nfpm/cmd/nfpm
- run: cp /tmp/out/txt-suite .
- run: if [ -z "$CIRCLE_TAG" ]; then echo "export CIRCLE_TAG=$(git describe --tags|cut -d'-' -f1);" >> $BASH_ENV; fi
- run: if [ -z "$CIRCLE_BUILD_NUM" ]; then echo "export CIRCLE_BUILD_NUM=$(git describe --tags|cut -d'-' -f2);" >> $BASH_ENV; fi
- run: MY_APP_VERSION=${CIRCLE_TAG} MY_APP_BUILDNUMBER=${CIRCLE_BUILD_NUM} go run github.com/goreleaser/nfpm/cmd/nfpm pkg --config ./build/package/nfpm_rpm.yaml --target golang-txt-suite-${CIRCLE_TAG}-${CIRCLE_BUILD_NUM}.x86_64.rpm
- run: MY_APP_VERSION=${CIRCLE_TAG} MY_APP_BUILDNUMBER=${CIRCLE_BUILD_NUM} go run github.com/goreleaser/nfpm/cmd/nfpm pkg --config ./build/package/nfpm_deb.yaml --target go_txt-suite-${CIRCLE_TAG}-${CIRCLE_BUILD_NUM}_amd64.deb
- run: mkdir -p out && cp *.rpm ./out/ && cp *.deb ./out/
- run: cp txt-suite ./out/
- run: cp golang-txt-suite-${CIRCLE_TAG}-${CIRCLE_BUILD_NUM}.x86_64.rpm artifact.rpm
- run: cp go_txt-suite-${CIRCLE_TAG}-${CIRCLE_BUILD_NUM}_amd64.deb artifact.deb
- persist_to_workspace:
root: out
paths:
- golang-txt-suite*.rpm
- go_txt-suite*.deb
- txt-suite
- store_artifacts:
path: artifact.rpm
destination: golang-txt-suite.rpm
- store_artifacts:
path: artifact.deb
destination: golang-txt-suite.deb
publish-github-release:
docker:
- image: cibuilds/github:0.10
steps:
- checkout
- attach_workspace:
at: /tmp/out
- run:
name: "Publish Release on GitHub"
command: |
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -draft -delete ${CIRCLE_TAG} /tmp/out/
workflows:
version: 2
main:
jobs:
- build:
filters:
branches:
only: /.*/
tags:
only: /.*/
- create_deb_rpm:
requires:
- build
filters:
branches:
only: /.*/
tags:
only: /.*/
- publish-github-release:
requires:
- build
- create_deb_rpm
filters:
tags:
# vX.Y.Z
only: /^v\d+\.\d+$/
branches:
ignore: /.*/