diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb new file mode 100644 index 0000000..e69de29 diff --git a/container-publish.gitlab-ci.yml b/container-publish.gitlab-ci.yml index c4929fd..1f58db5 100644 --- a/container-publish.gitlab-ci.yml +++ b/container-publish.gitlab-ci.yml @@ -23,7 +23,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: diff --git a/documentation/chapters/generalInformation.adoc b/documentation/chapters/generalInformation.adoc index bd14a70..bead214 100644 --- a/documentation/chapters/generalInformation.adoc +++ b/documentation/chapters/generalInformation.adoc @@ -25,8 +25,8 @@ include: - 'npm-test-template.gitlab-ci.yml' - 'container-publish.gitlab-ci.yml' - 'container-scan.gitlab-ci.yml' - - 'set-version-template.yml' - - 'sonar-template.yml' + - 'set-version-template.gitlab-ci.yml' + - 'push-tag-and-version-template.gitlab-ci.yml' test-image: diff --git a/documentation/chapters/pipelines/update-version-pipeline.adoc b/documentation/chapters/pipelines/update-version-pipeline.adoc new file mode 100644 index 0000000..d745afc --- /dev/null +++ b/documentation/chapters/pipelines/update-version-pipeline.adoc @@ -0,0 +1,102 @@ +: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' + files: + - '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[] +---- \ No newline at end of file diff --git a/documentation/chapters/templates/publish-image.adoc b/documentation/chapters/templates/publish-image.adoc new file mode 100644 index 0000000..5db62b1 --- /dev/null +++ b/documentation/chapters/templates/publish-image.adoc @@ -0,0 +1,18 @@ +:sourcedir: ../../../ + += Publish-Image-jib + +Baut mithilfe von jib ein Docker Image und läd es in der Docker Registry des Projekt hoch. +Dieser Schritt wird nur ausgeführt, wenn ein Tag gesetzt wird. + +.Variables +|=== +|Name |Description | Default Value +|MVN_VERSION | Bestimmt, ob die version von MAVEN gesetzt werden soll. +Falls das Projekt aus mehreren Poms besteht, kann `bevor_script:` benutzt werden. | "true" +|=== + +.publish-image-jib-template +---- +include::{sourcedir}/publish-image.yml[] +---- \ No newline at end of file diff --git a/documentation/chapters/templates/push-tag-and-version-template.adoc b/documentation/chapters/templates/push-tag-and-version-template.adoc new file mode 100644 index 0000000..6334557 --- /dev/null +++ b/documentation/chapters/templates/push-tag-and-version-template.adoc @@ -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[] +---- \ No newline at end of file diff --git a/documentation/chapters/templates/release-template.adoc b/documentation/chapters/templates/release-template.adoc new file mode 100644 index 0000000..6201492 --- /dev/null +++ b/documentation/chapters/templates/release-template.adoc @@ -0,0 +1,19 @@ +:sourcedir: ../../../ + += release-template + +This template provides a template for including the child release pipeline. + +For more information see the `update-version-pipeline` documentation. + +.Variables +|=== +|Name |Description | Default Value +|PARENT_PIPELINE_ID | The if of the parent pipeline. Needed to be able to use artifacts in the child pipeline | $CI_PIPELINE_ID +|=== + +.release-template +[source, yaml] +---- +include::{sourcedir}/release-template.gitlab-ci.yml[] +---- \ No newline at end of file diff --git a/documentation/chapters/templates/set-version-template.adoc b/documentation/chapters/templates/set-version-template.adoc new file mode 100644 index 0000000..d2f7393 --- /dev/null +++ b/documentation/chapters/templates/set-version-template.adoc @@ -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 +|SIMPLIFY +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.gitlab-ci.yml[] +---- \ No newline at end of file diff --git a/documentation/document.adoc b/documentation/document.adoc index c783dfb..76d3ad8 100644 --- a/documentation/document.adoc +++ b/documentation/document.adoc @@ -35,9 +35,19 @@ toc::[] include::chapters/generalInformation.adoc[leveloffset=1] == Misc Templates +//include::chapters/templates/sonar-template.adoc[leveloffset=2] +include::chapters/templates/container-publish.adoc[leveloffset=2] +include::chapters/templates/container-scan.adoc[leveloffset=2] -include::chapters/templates/container-publish.adoc[leveloffset=1] -include::chapters/templates/container-scan.adoc[leveloffset=1] +== Update Version + +=== Templates +include::chapters/templates/push-tag-and-version-template.adoc[leveloffset=3] +include::chapters/templates/set-version-template.adoc[leveloffset=3] +include::chapters/templates/release-template.adoc[leveloffset=3] + +=== Pipeline +include::chapters/pipelines/update-version-pipeline.adoc[leveloffset=3] == NPM Templates diff --git a/documentation/images/Release-Docker-Image-Pipeline.png b/documentation/images/Release-Docker-Image-Pipeline.png new file mode 100644 index 0000000..5b8ed74 Binary files /dev/null and b/documentation/images/Release-Docker-Image-Pipeline.png differ diff --git a/pipelines/update-version-pipeline.gitlab-ci.yml b/pipelines/update-version-pipeline.gitlab-ci.yml new file mode 100644 index 0000000..78f7a19 --- /dev/null +++ b/pipelines/update-version-pipeline.gitlab-ci.yml @@ -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 + diff --git a/push-tag-and-version-template.yml b/push-tag-and-version-template.yml new file mode 100644 index 0000000..57d13a6 --- /dev/null +++ b/push-tag-and-version-template.yml @@ -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 diff --git a/release-template.gitlab-ci.yml b/release-template.gitlab-ci.yml new file mode 100644 index 0000000..8a6f57e --- /dev/null +++ b/release-template.gitlab-ci.yml @@ -0,0 +1,11 @@ +.release-template: + stage: release + rules: + - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH + when: manual + - when: never + variables: + PARENT_PIPELINE_ID: $CI_PIPELINE_ID + trigger: + include: release.gitlab-ci.yml + strategy: depend \ No newline at end of file diff --git a/set-version-template.gitlab-ci.yml b/set-version-template.gitlab-ci.yml new file mode 100644 index 0000000..decb960 --- /dev/null +++ b/set-version-template.gitlab-ci.yml @@ -0,0 +1,14 @@ +.set-version: + stage: set-version + image: gitlab.exxcellent.de:4567/gilden/ci/exxcellent-increase-version-tool:2.2.0 + variables: + BUMP_VERSION: "major" + PREFIX: "" + OUTPUT: version + SIMPLIFY: "false" + TAG: "false" + script: + - increase-version + artifacts: + paths: + - $OUTPUT