Sign inSign up

cayro/gitlab-semantic-versioning

By cayro

•Updated over 6 years ago

Image
0

1.2K

cayro/gitlab-semantic-versioning repository overview

⁠gitlab-semantic-versioning

Docker image that can be used to automatically version projects.

⁠How is the version determined?

Versions are being maintained using git tags.

If no git tag is available, the first version update will result in version (current-date).1. If git tags are available, it will determine whether to update date part or the patch part, if the current date is different than the last tag's date newer tag will be (current-date).1, if current date is as the same date as the last tag's date newer tag will be an increment to the last tag's patch part.

⁠Prerequisites

⁠API token and group

To extract the labels from merge requests, we need an API token to access the Gitlab API. Unfortunately, GitLab doesn't yet support non-user specific access tokens⁠.

Ask your GitLab administrator to add a dummy user ${group_name}_npa to GitLab with access only to your project group. Log in with this user, and create a personal access token⁠ with api scope access.

Copy the generated API token and keep it available for the next section.

⁠Group-level variables

The NPA username and token need to be injected into the version-update container as environment variables. For this, we'll use group-level variables.

Go to your group's variables section under Settings -> CI / CD.

Add the following variables:

KeyValue
NPA_USERNAMEThe name of the NPA user created for your group: ${group_name}_npa
NPA_PASSWORDThe personal access token with API scope generated for the NPA user

⁠Pipeline configuration

The pipeline configuration below will:

-It demonstrates tagging the project and passing the tag to other stages.

stages:
  - version
  - echo

version:
  stage: version
  image: cayro/gitlab-semantic-versioning:latest
  tags:
    - runner-tag
  script:
    - python3 /version-update/version-update.py
    - TAG=$(git describe --tags --always)
    - echo "export TAG=$TAG" > .variables
  artifacts:
    paths:
      - .variables
  only:
    - develop

echo:
  stage: echo
  tags:
    - runner-tag
  only:
    - develop
  before_script:
    - source .variables
  script:
    - echo $TAG

Tag summary

Content type

Image

Digest

Size

94.1 MB

Last updated

over 6 years ago

docker pull cayro/gitlab-semantic-versioning