feat(UpdateVersion): Add templates and pipelines to update versions
This commit is contained in:
parent
4df6a0c6bb
commit
7e7d914a21
@ -1,3 +0,0 @@
|
||||
|
||||
A
|
||||
publish-image.yml,2/e/2eef21b10116aab77b6b014cb5adf007d2d2e128
|
||||
114
documentation/chapters/pipelines/update-version-pipeline.adoc
Normal file
114
documentation/chapters/pipelines/update-version-pipeline.adoc
Normal file
@ -0,0 +1,114 @@
|
||||
:sourcedir: ../../../pipelines
|
||||
|
||||
ifndef::imagesdir[]
|
||||
:imagesdir: ../../images
|
||||
endif::[]
|
||||
|
||||
= update-version-pipeline
|
||||
|
||||
This pipeline provides the jobs to increase the version, create a new tag and updates the changed files (version) the repository.
|
||||
|
||||
It can be extended to push a docker image to a docker registry.
|
||||
|
||||
.Variables
|
||||
|===
|
||||
|Name |Description | Default Value
|
||||
|
||||
|BUMP_VERSION | defines the version bump | "major"
|
||||
|===
|
||||
|
||||
== Setup
|
||||
|
||||
This pipeline should be included as a child-pipeline in your gitlab-ci pipeline.
|
||||
You then can add an individual release job for each kind of version bump.
|
||||
|
||||
NOTE: You only need the variable `PARENT_PIPELINE_ID` , if you use an https://docs.gitlab.com/ee/ci/yaml/README.html#artifact-downloads-to-child-pipelines[artfact of you parent-pipeline in your child pipeline]
|
||||
|
||||
In your gitlab-ci.yml include the following
|
||||
|
||||
.gitlab-ci.yml
|
||||
[source, yaml]
|
||||
----
|
||||
stages:
|
||||
- release
|
||||
|
||||
a.major-image-release:
|
||||
stage: release
|
||||
when: manual
|
||||
only:
|
||||
- master
|
||||
variables:
|
||||
BUMP_VERSION: "major"
|
||||
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
|
||||
trigger:
|
||||
include: release.gitlab-ci.yml
|
||||
strategy: depend
|
||||
|
||||
b.minor-image-release:
|
||||
stage: release
|
||||
when: manual
|
||||
only:
|
||||
- master
|
||||
variables:
|
||||
BUMP_VERSION: "minor"
|
||||
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
|
||||
trigger:
|
||||
include: release.gitlab-ci.yml
|
||||
strategy: depend
|
||||
|
||||
c.patch-image-release:
|
||||
stage: release
|
||||
when: manual
|
||||
only:
|
||||
- master
|
||||
variables:
|
||||
BUMP_VERSION: "patch"
|
||||
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
|
||||
trigger:
|
||||
include: release.gitlab-ci.yml
|
||||
strategy: depend
|
||||
|
||||
----
|
||||
|
||||
Create a child-pipeline file called `release.gitlab-ci.yml` and include the following:
|
||||
|
||||
.release.gitlab-ci.yml
|
||||
[source, yaml]
|
||||
----
|
||||
stages:
|
||||
- set-version
|
||||
- push-tag-and-version
|
||||
- release
|
||||
|
||||
include:
|
||||
- project: 'gilden/ci/gitlab-ci-templates'
|
||||
ref: 'master'
|
||||
file:
|
||||
- '/pipelines/update-version-pipeline.yml'
|
||||
- 'push-image.yml'
|
||||
|
||||
# This is optional
|
||||
push-docker-image:
|
||||
stage: release
|
||||
extends: .push-image-kaniko
|
||||
# You only need NEED if you use a artifact from your parent pipeline to build the image
|
||||
needs:
|
||||
- pipeline: $PARENT_PIPELINE_ID
|
||||
#Get artifacts from parent pipeline #https://docs.gitlab.com/ee/ci/yaml/README.html#artifact-downloads-to-child-pipelines
|
||||
job: mvn-build
|
||||
- job: increase-version
|
||||
- job: push-tag-version
|
||||
----
|
||||
|
||||
You pipeline then looks like the following:
|
||||
|
||||
.Release Pipeline
|
||||
image::Release-Docker-Image-Pipeline.png[]
|
||||
|
||||
== Pipeline
|
||||
|
||||
.update-version-pipeline
|
||||
[source, yaml]
|
||||
----
|
||||
include::{sourcedir}/update-version-pipeline.yml[]
|
||||
----
|
||||
@ -12,7 +12,7 @@ Dieser Schritt wird nur ausgeführt, wenn ein Tag gesetzt wird.
|
||||
Falls das Projekt aus mehreren Poms besteht, kann `bevor_script:` benutzt werden. | "true"
|
||||
|===
|
||||
|
||||
.sonar-template
|
||||
.publish-image-jib-template
|
||||
----
|
||||
include::{sourcedir}/publish-image.yml[]
|
||||
----
|
||||
@ -0,0 +1,20 @@
|
||||
:sourcedir: ../../../
|
||||
|
||||
= push-tag-and-version-template
|
||||
|
||||
This template creates a new tag und updates the version of your project in the repository.
|
||||
For more details: https://gitlab.exxcellent.de/gilden/ci/exxcellent-ssh-tool[Gilde CI/CD: exxcellent-ssh-tool].
|
||||
|
||||
|
||||
.Variables
|
||||
|===
|
||||
|Name |Description | Default Value
|
||||
|ARTIFACT | the name of the artifact the new version is written to by the `set-version` job |"version"
|
||||
|MVN_VERSION | defines if the `mvn version:set` command will be run | "true"
|
||||
|===
|
||||
|
||||
.push-tag-and-version-template
|
||||
[source, yaml]
|
||||
----
|
||||
include::{sourcedir}/push-tag-and-version-template.yml[]
|
||||
----
|
||||
27
documentation/chapters/templates/set-version-template.adoc
Normal file
27
documentation/chapters/templates/set-version-template.adoc
Normal file
@ -0,0 +1,27 @@
|
||||
:sourcedir: ../../../
|
||||
|
||||
= set-version-template
|
||||
|
||||
This template provides the job for increasing the tag version.
|
||||
For more details look at https://gitlab.exxcellent.de/gilden/ci/exxcellent-increase-version-tool[Gilde CI/CD: exxcellent-increase-version-tool].
|
||||
|
||||
|
||||
.Variables
|
||||
|===
|
||||
|Name |Description | Default Value
|
||||
|BUMP_VERSION | defines the version bump | "major"
|
||||
|PREFIX | the prefix for the tag | ""
|
||||
|OUTPUT | defines where the updated version is written to | version
|
||||
|SIMPLITY
|
||||
a|
|
||||
* "false":
|
||||
** use semver version number. e.g: 1.2.3+build.6
|
||||
* "true":
|
||||
** use more traditional version number. e.g: 1.2.3.6 | "false"
|
||||
|===
|
||||
|
||||
.set-version-template
|
||||
[source, yaml]
|
||||
----
|
||||
include::{sourcedir}/set-version-template.yml[]
|
||||
----
|
||||
@ -35,19 +35,28 @@ toc::[]
|
||||
include::chapters/generalInformation.adoc[leveloffset=1]
|
||||
|
||||
== Misc Templates
|
||||
//include::chapters/templates/sonar-template.adoc[leveloffset=1]
|
||||
include::chapters/templates/publish-image.adoc[leveloffset=2]
|
||||
|
||||
== Update Version
|
||||
|
||||
=== Templates
|
||||
include::chapters/templates/push-tag-and-version-template.adoc[leveloffset=3]
|
||||
include::chapters/templates/set-version-template.adoc[leveloffset=3]
|
||||
|
||||
=== Pipeline
|
||||
include::chapters/pipelines/update-version-pipeline.adoc[leveloffset=3]
|
||||
|
||||
include::chapters/templates/sonar-template.adoc[leveloffset=1]
|
||||
include::chapters/templates/publish-image.adoc[leveloffset=1]
|
||||
|
||||
== NPM Templates
|
||||
|
||||
include::chapters/templates/npm-dependencies-template.adoc[leveloffset=1]
|
||||
include::chapters/templates/npm-build-template.adoc[leveloffset=1]
|
||||
include::chapters/templates/npm-lint-template.adoc[leveloffset=1]
|
||||
include::chapters/templates/npm-test-template.adoc[leveloffset=1]
|
||||
include::chapters/templates/npm-dependencies-template.adoc[leveloffset=2]
|
||||
include::chapters/templates/npm-build-template.adoc[leveloffset=2]
|
||||
include::chapters/templates/npm-lint-template.adoc[leveloffset=2]
|
||||
include::chapters/templates/npm-test-template.adoc[leveloffset=2]
|
||||
|
||||
== Maven Templates
|
||||
|
||||
include::chapters/templates/maven-dependencies-template.adoc[leveloffset=1]
|
||||
include::chapters/templates/maven-build-template.adoc[leveloffset=1]
|
||||
include::chapters/templates/maven-verify-template.adoc[leveloffset=1]
|
||||
include::chapters/templates/maven-dependencies-template.adoc[leveloffset=2]
|
||||
include::chapters/templates/maven-build-template.adoc[leveloffset=2]
|
||||
include::chapters/templates/maven-verify-template.adoc[leveloffset=2]
|
||||
BIN
documentation/images/Release-Docker-Image-Pipeline.png
Normal file
BIN
documentation/images/Release-Docker-Image-Pipeline.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
22
pipelines/update-version-pipeline.yml
Normal file
22
pipelines/update-version-pipeline.yml
Normal file
@ -0,0 +1,22 @@
|
||||
stages:
|
||||
- set-version
|
||||
- push-tag-and-version
|
||||
|
||||
include:
|
||||
- project: 'gilden/ci/gitlab-ci-templates'
|
||||
ref: 'master'
|
||||
file:
|
||||
- 'set-version-template.yml'
|
||||
- 'push-tag-and-version-template.yml'
|
||||
|
||||
variables:
|
||||
BUMP_VERSION: "major"
|
||||
|
||||
increase-version:
|
||||
stage: set-version
|
||||
extends: .set-version
|
||||
|
||||
push-tag-and-version:
|
||||
stage: push-tag-and-version
|
||||
extends: .push-tag-and-version
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
.publish-image-kaniko:
|
||||
image:
|
||||
name: gcr.io/kaniko-project/executor:debug
|
||||
name: gcr.io/kaniko-project/executor:v1.6.0-debug
|
||||
entrypoint: [ "" ]
|
||||
stage: package
|
||||
rules:
|
||||
|
||||
20
push-tag-and-version-template.yml
Normal file
20
push-tag-and-version-template.yml
Normal file
@ -0,0 +1,20 @@
|
||||
.push-tag-and-version:
|
||||
stage: push-tag-and-version
|
||||
image: gitlab.exxcellent.de:4567/gilden/ci/exxcellent-ssh-tool:1.2.0
|
||||
variables:
|
||||
ARTIFACT: "version"
|
||||
MVN_VERSION: "true"
|
||||
before_script:
|
||||
- setup-ssh
|
||||
script:
|
||||
- export VERSION="0.0.0"
|
||||
- "[ -f ./$ARTIFACT ] && export VERSION=$(cat ./$ARTIFACT)"
|
||||
- echo $VERSION
|
||||
- pull
|
||||
- echo $VERSION > $ARTIFACT
|
||||
- curl https://img.shields.io/badge/Version-$VERSION-green.svg --output $ARTIFACT.svg
|
||||
- >
|
||||
if [ "${MVN_VERSION}" == "true" ]; then
|
||||
mvn versions:set -DnewVersion=$VERSION -DgenerateBackupPoms=false
|
||||
fi
|
||||
- push $VERSION
|
||||
22
set-version-template.yml
Normal file
22
set-version-template.yml
Normal file
@ -0,0 +1,22 @@
|
||||
.set-version:
|
||||
stage: set-version
|
||||
image: gitlab.exxcellent.de:4567/gilden/ci/exxcellent-increase-version-tool:2.1.1
|
||||
variables:
|
||||
BUMP_VERSION: "major"
|
||||
PREFIX: ""
|
||||
OUTPUT: version
|
||||
SIMPLIFY: "false"
|
||||
script:
|
||||
- >
|
||||
if [ "${PREFIX}" != "" ]; then
|
||||
if [ "${SIMPLIFY} == "true" ]; then
|
||||
gen-push --version $BUMP_VERSION --tag "false" --prefix $PREFIX --simplify > $OUTPUT
|
||||
else
|
||||
gen-push --version $BUMP_VERSION --tag "false" --prefix $PREFIX > $OUTPUT
|
||||
fi
|
||||
else
|
||||
gen-push --version $BUMP_VERSION --tag "false" > $OUTPUT
|
||||
fi
|
||||
artifacts:
|
||||
paths:
|
||||
- $OUTPUT
|
||||
Loading…
Reference in New Issue
Block a user