Skip to content

Implement commitizen change #90

@AndrewRoberts1

Description

@AndrewRoberts1
  1. Add this .cz.yaml commitizen config file (version is the current code version):

YAML

commitizen:  
  tag_format: v$version  
  version: 1.4.0  
  version_files:  
    - k8s live/manifest-api.yaml:join-the-dots-infra/api  
    - k8s live/manifest-web.yaml:join-the-dots-infra/web
  1. Add an access token to the repository with read/write repo permissions. Name it ci-runner or something.
  2. Add the token and its username (in the format token-name:token-value, e.g. ci-runner:abcd1234) to the CI/CD variables under Settings > CI/CD > Variables. Name it CI_PAT and check the "masked" box to make it hidden.
  3. Add this variable to .gitlab-ci.yml: CI_REMOTE_URL: https://$CI_PAT@$CI_SERVER_HOST/informatics/join-the-dots-infra.git
  4. You need a variable that's the code version without the v, so to avoid having to change everything else I'd change the variables to this:

YAML

CODE_VERSION_NUMBER: 1.4.0
CODE_VERSION: v$CODE_VERSION_NUMBER
  1. This is the commitizen bump job:

YAML

bump-live:
  stage: build-live
  image: python:3.12
  before_script:
    - pip install -U commitizen
    - pip install -U cz-nhm
  script:
    - git config user.name "$GITLAB_USER_NAME"
    - git config user.email "$GITLAB_USER_EMAIL"
    - git remote set-url --push origin $CI_REMOTE_URL
    - git checkout -b $CI_COMMIT_BRANCH
    - cz -nr 21 bump --yes --no-verify --allow-no-commit $CODE_VERSION_NUMBER
    - git push origin $CI_COMMIT_BRANCH:$CI_COMMIT_REF_NAME
    - git push origin $CODE_VERSION
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

I would add it to the build-live stage and then add it to the dependencies for build-live-web and build-live-api (so it has to run first), but you can decide what works best. You can remove the last git push if you don't want tags.

When you want to push a new version, you change the CODE_VERSION_NUMBER variable and (theoretically) everything else should update automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions