Created
March 21, 2018 01:15
-
-
Save ninjarobot/ae46e4da20e795f6f07c12418b2beaed to your computer and use it in GitHub Desktop.
Makefile for Large .NET Project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HOME:=$(shell pwd) | |
NAME:=someLargeProject | |
DOCKER_REPO := my.internal.repo | |
DOCKER_REPO_DIR := mystuff | |
BUILD_CONTAINER := microsoft/dotnet:2-sdk | |
BASE_VERSION = 2.0 | |
BUILD_NUMBER ?= 1 | |
VERSION = ${BASE_VERSION}.${BUILD_NUMBER} | |
all: get-dependencies package | |
build: | |
dotnet build /p:Configuration=Release MyLargeProject.sln /p:Version=${VERSION} | |
package: build | |
dotnet pack MyLargeProject/MyLargeProject.sln --output ../nugets | |
get-dependencies: | |
dotnet restore | |
test: get-dependencies | |
dotnet test ServerTestProj/ServerTestProj.fsproj | |
dotnet test ClientTestProj/ClientTestProj.fsproj | |
docker-test: | |
docker run --name ${NAME}-test -v `pwd`:/src --rm -i ${BUILD_CONTAINER} \ | |
/bin/bash -c "cd /src; dotnet test ServerTestProj/ServerTestProj.fsproj; dotnet test ClientTestProj/ClientTestProj.fsproj" | |
docker-build: | |
MSYS_NO_PATHCONV=1 docker run --name ${NAME}-build -v `pwd`:/src --rm -i ${BUILD_CONTAINER} \ | |
/bin/bash -c "cd /src; dotnet restore && dotnet publish -c Release /p:Version=${VERSION}" | |
docker-image: | |
MSYS_NO_PATHCONV=1 docker build -t ${DOCKER_REPO}/${DOCKER_REPO_DIR}/${NAME}:latest \ | |
-t ${DOCKER_REPO}/${DOCKER_REPO_DIR}/${NAME}:${VERSION} \ | |
-t ${DOCKER_REPO}/${DOCKER_REPO_DIR}/${NAME}:${BASE_VERSION} . | |
clean: | |
rm -rf nugets/ | |
rm -rf bin/helm bin/yaml | |
rm -rf **/bin/ **/obj/ | |
bin/helm: | |
mkdir -p bin | |
curl -L https://kubernetes-helm.storage.googleapis.com/helm-v2.7.0-linux-amd64.tar.gz -o /tmp/helm-v2.7.0-linux-amd64.tar.gz | |
tar xvfz /tmp/helm-v2.7.0-linux-amd64.tar.gz -C /tmp | |
mv /tmp/linux-amd64/helm bin/helm | |
rm -rf /tmp/linux-amd64 | |
rm -f /tmp/helm-v2.7.0-linux-amd64.tar.gz | |
bin/yaml: | |
mkdir -p bin | |
curl -L https://github.com/mikefarah/yaml/releases/download/1.13.1/yaml_linux_amd64 -o bin/yaml | |
chmod +x bin/yaml | |
.PHONY: helm | |
helm: bin/helm bin/yaml | |
./bin/helm init -c | |
./bin/helm repo add myhelmrepo https://some.repo/my-helm-repo/ | |
./bin/helm dep up HelmCharts/${NAME}/ | |
./bin/yaml w -i HelmCharts/${NAME}/values.yaml image.tag ${VERSION} | |
./bin/yaml w -i HelmCharts/${NAME}/Chart.yaml version ${VERSION} | |
./bin/helm package HelmCharts/${NAME}/ --save=false -d HelmCharts/ | |
curl -X PUT -u myuser:my_secret_token -f mychart.tgz https://some.repo/my-helm-repo/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment