102 lines
2.3 KiB
Plaintext
102 lines
2.3 KiB
Plaintext
: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.
|
|
|
|
== 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[artifact of you parent-pipeline in your child pipeline]
|
|
|
|
In your gitlab-ci.yml include the following
|
|
|
|
.gitlab-ci.yml
|
|
[source, yaml]
|
|
----
|
|
stages:
|
|
- release
|
|
|
|
include:
|
|
- project: 'gilden/ci/gitlab-ci-templates'
|
|
ref: 'master'
|
|
file:
|
|
- 'release-template.yml'
|
|
|
|
a.major-release:
|
|
extends: .release-template
|
|
variables:
|
|
BUMP_VERSION: "major"
|
|
|
|
b.minor-release:
|
|
extends: .release-template
|
|
variables:
|
|
BUMP_VERSION: "minor"
|
|
|
|
c.patch-release:
|
|
extends: .release-template
|
|
variables:
|
|
BUMP_VERSION: "patch"
|
|
|
|
d.prerelease-release:
|
|
extends: .release-template
|
|
variables:
|
|
BUMP_VERSION: "prerelease"
|
|
|
|
e.build-release:
|
|
extends: .release-template
|
|
variables:
|
|
BUMP_VERSION: "build"
|
|
|
|
----
|
|
|
|
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.gitlab-ci.yml[]
|
|
---- |