Files
yml/pipelines/build-container.yml

103 lines
2.9 KiB
YAML

stages:
- versioning
- build
version:
image: gittools/gitversion:5.12.0
stage: versioning
script:
# Begin of version-number.sh
- |
#Check for configuration
echo "mode: ContinuousDeployment
continuous-delivery-fallback-tag: ''
branches:
master:
mode: ContinuousDeployment
tag: 'dev'
increment: Minor
track-merge-target: true
tracks-release-branches: true
is-release-branch: false
prevent-increment-of-merged-branch-version: false
release:
regex: release?[/]
mode: ContinuousDeployment
increment: Patch
tag: ''
is-release-branch: true
prevent-increment-of-merged-branch-version: true
feature:
regex: feature?[/]
mode: ContinuousDeployment
increment: Inherit
tag: 'alpha'
is-release-branch: false
prevent-increment-of-merged-branch-version: true
ignore:
sha: []
" > GitVersion.yml
version=$(/tools/dotnet-gitversion /showvariable NuGetVersionV2)
echo "VERSION=$version" >> version.env
cat version.env
# End of version-number.sh
artifacts:
reports:
dotenv: version.env
build-container:
image: registry.durp.info/docker:20.10.16
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: tcp://docker:2375
#DOCKER_TLS_CERTDIR: "/certs"
services:
- docker:20.10.16-dind
stage: build
script:
# Begin of docker-login.sh
- |
#login to docker
docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY/$CI_PROJECT_PATH
# End of docker-login.sh
# Begin of docker-build.sh
- |
#Build Docker Container
docker build -t $CI_REGISTRY/$CI_PROJECT_PATH:$VERSION -t $CI_REGISTRY/$CI_PROJECT_PATH:latest .
docker push "$CI_REGISTRY/$CI_PROJECT_PATH:latest"
docker push "$CI_REGISTRY/$CI_PROJECT_PATH:$VERSION"
# End of docker-build.sh
needs:
- job: version
artifacts: true
only:
- main
HelmChart:
image: registry.durp.info/dtzar/helm-kubectl
stage: build
script:
# Begin of helm-addrepo.sh
- |
#Helm repo add
helm repo add --username gitlab-ci-token --password ${CI_JOB_TOKEN} ${CI_PROJECT_NAME} ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/stable
# End of helm-addrepo.sh
# Begin of helm-package.sh
- |
#Helm Package
for chart in charts/*; do
if [ -d "$chart" ]; then
helm package "$chart" -d ./packages --version ${VERSION}
fi
done
# End of helm-package.sh
# Begin of helm-push.sh
- "#Helm Push \n \nhelm plugin install https://github.com/chartmuseum/helm-push\nfor chart in packages/*; do\n helm cm-push ./$chart ${CI_PROJECT_NAME}\ndone\n"
# End of helm-push.sh
needs:
- job: version
artifacts: true
only:
- main