Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
set -e
USERNAME=$1
PROJECTNAME=$2
CII_PROJECT_ID=$3
if [[ -z "${PROJECTNAME}" || -z "${USERNAME}" || -z "${CII_PROJECT_ID}" ]]; then
echo "ProjectName, CII project ID and/or Username should not be empty"
exit 1
fi
echo "[![Build Status](https://travis-ci.org/${USERNAME}/${PROJECTNAME}.svg?branch=master)](https://travis-ci.org/${USERNAME}/${PROJECTNAME})
[![Go Report Card](https://goreportcard.com/badge/github.com/${USERNAME}/${PROJECTNAME})](https://goreportcard.com/report/github.com/${USERNAME}/${PROJECTNAME})
![Docker Pulls](https://img.shields.io/docker/pulls/utrecht/${PROJECTNAME}.svg)
![Issues](https://img.shields.io/github/issues-raw/${USERNAME}/${PROJECTNAME}.svg)
![Pull requests](https://img.shields.io/github/issues-pr-raw/${USERNAME}/${PROJECTNAME}.svg)
![Total downloads](https://img.shields.io/github/downloads/${USERNAME}/${PROJECTNAME}/total.svg)
![License](https://img.shields.io/github/license/${USERNAME}/${PROJECTNAME}.svg)
![Repository Size](https://img.shields.io/github/repo-size/${USERNAME}/${PROJECTNAME}.svg)
![Contributors](https://img.shields.io/github/contributors/${USERNAME}/${PROJECTNAME}.svg)
![Commit activity](https://img.shields.io/github/commit-activity/m/${USERNAME}/${PROJECTNAME}.svg)
![Last commit](https://img.shields.io/github/last-commit/${USERNAME}/${PROJECTNAME}.svg)
![Release date](https://img.shields.io/github/release-date/${USERNAME}/${PROJECTNAME}.svg)
![Latest Production Release Version](https://img.shields.io/github/release/${USERNAME}/${PROJECTNAME}.svg)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=${USERNAME}_${PROJECTNAME}&metric=bugs)](https://sonarcloud.io/dashboard?id=${USERNAME}_${PROJECTNAME})
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=${USERNAME}_${PROJECTNAME}&metric=code_smells)](https://sonarcloud.io/dashboard?id=${USERNAME}_${PROJECTNAME})
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=${USERNAME}_${PROJECTNAME}&metric=coverage)](https://sonarcloud.io/dashboard?id=${USERNAME}_${PROJECTNAME})
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=${USERNAME}_${PROJECTNAME}&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=${USERNAME}_${PROJECTNAME})
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=${USERNAME}_${PROJECTNAME}&metric=ncloc)](https://sonarcloud.io/dashboard?id=${USERNAME}_${PROJECTNAME})
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=${USERNAME}_${PROJECTNAME}&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=${USERNAME}_${PROJECTNAME})
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=${USERNAME}_${PROJECTNAME}&metric=alert_status)](https://sonarcloud.io/dashboard?id=${USERNAME}_${PROJECTNAME})
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=${USERNAME}_${PROJECTNAME}&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=${USERNAME}_${PROJECTNAME})
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=${USERNAME}_${PROJECTNAME}&metric=security_rating)](https://sonarcloud.io/dashboard?id=${USERNAME}_${PROJECTNAME})
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=${USERNAME}_${PROJECTNAME}&metric=sqale_index)](https://sonarcloud.io/dashboard?id=${USERNAME}_${PROJECTNAME})
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=${USERNAME}_${PROJECTNAME}&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=${USERNAME}_${PROJECTNAME})
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/${CII_PROJECT_ID}/badge)](https://bestpractices.coreinfrastructure.org/projects/${CII_PROJECT_ID})
[![codecov](https://codecov.io/gh/${USERNAME}/${PROJECTNAME}/branch/master/graph/badge.svg)](https://codecov.io/gh/${USERNAME}/${PROJECTNAME})
[![BCH compliance](https://bettercodehub.com/edge/badge/${USERNAME}/${PROJECTNAME}?branch=master)](https://bettercodehub.com/results/${USERNAME}/${PROJECTNAME})"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
echo "language: go
go:
- 1.12.5
env:
global:
- SHA512_CMD=sha512sum
- GO111MODULE=on
matrix:
include:
- os: linux
dist: bionic
- os: osx
env: SHA512_CMD="shasum -a 512"
- os: windows
addons:
sonarcloud:
organization: ${USERNAME}-github
token:
secure: \$SONAR_TOKEN
script:
- diff -u <(echo -n) <(gofmt -d ./)
- export DELIVERABLE="${PROJECTNAME}-\${TRAVIS_OS_NAME}"
- if [ "\$TRAVIS_OS_NAME" == "linux" ]; then go test -short -cover -v -coverprofile=coverage.txt -covermode=atomic ./...; fi
- go build -o \$DELIVERABLE
- \$SHA512_CMD \$DELIVERABLE > \${DELIVERABLE}.sha512.txt
- if [ "\$TRAVIS_OS_NAME" == "linux" ] && [ "\$TRAVIS_PULL_REQUEST" == "false" ]; then sonar-scanner -Dsonar.projectKey=${USERNAME}_${PROJECTNAME} -Dsonar.sources=. -Dsonar.host.url=https://sonarcloud.io -Dsonar.coverage.exclusions=cmd/**,**/*_test.go -Dsonar.go.coverage.reportPaths="coverage.txt"; fi
- if [ "\$TRAVIS_OS_NAME" == "linux" ] && [ "\$TRAVIS_PULL_REQUEST" == "false" ]; then bash <(curl -s https://codecov.io/bash); fi
deploy:
provider: releases
api_key: \$GITHUB_TOKEN
file:
- \$DELIVERABLE
- \${DELIVERABLE}.sha512.txt
skip_cleanup: true
on:
tags: true"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment