diff --git a/.make-release-support b/.make-release-support deleted file mode 100644 index ccfc1f7..0000000 --- a/.make-release-support +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 Xebia Nederland B.V. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -function hasChanges() { - test -n "$(git status -s .)" -} - -function getRelease() { - awk -F= '/^release=/{print $2}' .release -} - -function getBaseTag() { - sed -n -e "s/^release=\(.*\)$(getRelease)\$/\1/p" .release -} - -function getTag() { - if [ -z "$1" ] ; then - awk -F= '/^release/{print $2}' .release - else - echo "$(getBaseTag)$1" - fi -} - -function setRelease() { - if [ -n "$1" ] ; then - sed -i.x -e "s/^release=.*/release=$(getTag $1)/" .release - sed -i.x -e "s/^release=.*/release=$1/g" .release - rm -f .release.x - runPreTagCommand "$1" - else - echo "ERROR: missing release version parameter " >&2 - return 1 - fi -} - -function runPreTagCommand() { - if [ -n "$1" ] ; then - COMMAND=$(sed -n -e "s/@@RELEASE@@/$1/g" -e 's/^pre_tag_command=\(.*\)/\1/p' .release) - if [ -n "$COMMAND" ] ; then - if ! OUTPUT=$(bash -c "$COMMAND" 2>&1) ; then echo $OUTPUT >&2 && exit 1 ; fi - fi - else - echo "ERROR: missing release version parameter " >&2 - return 1 - fi -} - -function tagExists() { - tag=${1:-$(getTag)} - test -n "$tag" && test -n "$(git tag | grep "^$tag\$")" -} - -function differsFromRelease() { - tag=$(getTag) - ! tagExists $tag || test -n "$(git diff --shortstat -r $tag .)" -} - -function getVersion() { - result=$(getRelease) - - if differsFromRelease; then - result="$result-$(git log -n 1 --format=%h .)" - fi - - if hasChanges ; then - result="$result-dirty" - fi - echo $result -} - -function nextPatchLevel() { - version=${1:-$(getRelease)} - gittag=$(git describe --abbrev=0 --tags) || gittag=-1; - if [ "$version" = "$gittag" ] - then - primary_version=$(echo $version | cut -d- -f1) - major_and_minor=$(echo $version | cut -d- -f2 | cut -d. -f1,2) - patch=$(echo $version | cut -d- -f2 | cut -d. -f3) - version=$(printf "%s-%s.%d" $primary_version $major_and_minor $(($patch + 1))) - else - primary_version=$(echo $version | cut -d- -f1) - major_and_minor=$(echo $version | cut -d- -f2 | cut -d. -f1,2) - patch=$(echo $version | cut -d- -f2 | cut -d. -f3) - version=$(printf "%s-%s.%d" $primary_version $major_and_minor $(($patch))) - fi - echo $version -} - -function nextMinorLevel() { - version=${1:-$(getRelease)} - primary_version=$(echo $version | cut -d- -f1) - major=$(echo $version | cut -d- -f2 | cut -d. -f1); - minor=$(echo $version | cut -d- -f2 | cut -d. -f2) - version=$(printf "%s-%d.%d.0" $primary_version $major $(($minor + 1))) ; - echo $version -} - -function nextMajorLevel() { - version=${1:-$(getRelease)} - primary_version=$(echo $version | cut -d- -f1) - major=$(echo $version | cut -d- -f2 | cut -d. -f1); - version=$(printf "%s-%d.0.0" $primary_version $(($major + 1))) - echo $version -} -function checkIfStatusChanged(){ - if [[ `git status --porcelain` ]]; then - git add . - git commit -m "bumped to version $1" ; - git push - fi -} \ No newline at end of file diff --git a/.release b/.release deleted file mode 100644 index 9b6045a..0000000 --- a/.release +++ /dev/null @@ -1 +0,0 @@ -release=2.9.5-1.0.6 diff --git a/Jenkinsfile b/Jenkinsfile index 31851d0..d56b523 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,14 +1,7 @@ #!/usr/bin/env groovy -@Library('github.com/stakater/fabric8-pipeline-library@master') +@Library('github.com/stakater/fabric8-pipeline-library@master') _ -def versionPrefix = "" -try { - versionPrefix = VERSION_PREFIX -} catch (Throwable e) { - versionPrefix = "1.0" -} - -pushDockerImageFromMakefile { - versionPrefix = versionPrefix +pushDockerImage { dockerRegistryURL = "docker.io" + imagePrefix = "2.9.5" } \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index c7745fa..0000000 --- a/Makefile +++ /dev/null @@ -1 +0,0 @@ -include Makefile.mk diff --git a/Makefile.mk b/Makefile.mk deleted file mode 100644 index 0903913..0000000 --- a/Makefile.mk +++ /dev/null @@ -1,107 +0,0 @@ -# -# Copyright 2015 Xebia Nederland B.V. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# If you set the environment variables with same name as variables then they will be used otherwise default -# values will be used. -REGISTRY_HOST ?= docker.io -USERNAME ?= stakater -NAME ?= jenkins - -RELEASE_SUPPORT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/.make-release-support -IMAGE=$(REGISTRY_HOST)/$(USERNAME)/$(NAME) - -VERSION=$(shell . $(RELEASE_SUPPORT) ; getVersion) -# TAG=$(shell . $(RELEASE_SUPPORT) ; getVersion) - -SHELL=/bin/bash - -.PHONY: pre-build docker-build post-build build release patch-release minor-release major-release tag check-status check-release showver \ - push pre-push do-push post-push - -build: pre-build docker-build post-build - -pre-build: - -post-build: - -pre-push: - -post-push: - -docker-build: .release - docker build $(DOCKER_BUILD_ARGS) -t $(IMAGE):$(VERSION) . --network=host - @DOCKER_MAJOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f1) ; \ - DOCKER_MINOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f2) ; \ - if [ $$DOCKER_MAJOR -eq 1 ] && [ $$DOCKER_MINOR -lt 10 ] ; then \ - echo docker tag -f $(IMAGE):$(VERSION) $(IMAGE):latest ;\ - docker tag -f $(IMAGE):$(VERSION) $(IMAGE):latest ;\ - else \ - echo docker tag $(IMAGE):$(VERSION) $(IMAGE):latest ;\ - docker tag $(IMAGE):$(VERSION) $(IMAGE):latest ; \ - fi - -.release: - @echo "release=0.0.0" > .release - @echo INFO: .release created - @cat .release - - -release: check-status check-release build push - -push: pre-push do-push post-push - -do-push: - docker push $(IMAGE):$(VERSION) - docker push $(IMAGE):latest - -snapshot: build push - -showver: .release - @. $(RELEASE_SUPPORT); getVersion - -tag-patch-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextPatchLevel) -tag-patch-release: .release tag - -tag-minor-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextMinorLevel) -tag-minor-release: .release tag - -tag-major-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextMajorLevel) -tag-major-release: .release tag - -patch-release: tag-patch-release release - @echo $(VERSION) - -minor-release: tag-minor-release release - @echo $(VERSION) - -major-release: tag-major-release release - @echo $(VERSION) - -tag: TAG=$(shell . $(RELEASE_SUPPORT) ; getVersion) -tag: check-status - @. $(RELEASE_SUPPORT) ; ! tagExists $(VERSION) || (echo "ERROR: tag $(VERSION) for version $(VERSION) already tagged in git" >&2 && exit 1) ; - @. $(RELEASE_SUPPORT) ; setRelease $(VERSION) - @. $(RELEASE_SUPPORT) ; checkIfStatusChanged $(VERSION) - git tag $(VERSION) - git push --tags - # @ if [ -n "$(shell git remote -v)" ] ; then git push --tags ; else echo 'no remote to push tags to' ; fi - -check-status: - @. $(RELEASE_SUPPORT) ; ! hasChanges || (echo "ERROR: there are still outstanding changes" >&2 && exit 1) ; - -check-release: .release - @. $(RELEASE_SUPPORT) ; tagExists $(VERSION) || (echo "ERROR: version not yet tagged in git. make [minor,major,patch]-release." >&2 && exit 1) ; - @. $(RELEASE_SUPPORT) ; ! differsFromRelease $(VERSION) || (echo "ERROR: current directory differs from tagged $(VERSION). make [minor,major,patch]-release." ; exit 1)