{"id":17859313,"url":"https://github.com/dex4er/gitlab-ci-semver-labels","last_synced_at":"2026-01-20T22:01:59.074Z","repository":{"id":166216923,"uuid":"641609789","full_name":"dex4er/gitlab-ci-semver-labels","owner":"dex4er","description":"Bump the semver for a Gitlab CI project","archived":false,"fork":false,"pushed_at":"2026-01-10T05:44:24.000Z","size":112,"stargazers_count":1,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-11T01:40:13.138Z","etag":null,"topics":["ci","devops","gitlab","hacktoberfest","semver"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dex4er.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-16T20:46:50.000Z","updated_at":"2025-03-24T01:57:28.000Z","dependencies_parsed_at":"2024-01-17T21:36:38.157Z","dependency_job_id":"bc1b7b69-c620-4c93-b4dc-2600881fc7b7","html_url":"https://github.com/dex4er/gitlab-ci-semver-labels","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/dex4er/gitlab-ci-semver-labels","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dex4er%2Fgitlab-ci-semver-labels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dex4er%2Fgitlab-ci-semver-labels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dex4er%2Fgitlab-ci-semver-labels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dex4er%2Fgitlab-ci-semver-labels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dex4er","download_url":"https://codeload.github.com/dex4er/gitlab-ci-semver-labels/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dex4er%2Fgitlab-ci-semver-labels/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28615547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T21:52:42.722Z","status":"ssl_error","status_checked_at":"2026-01-20T21:52:20.513Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","devops","gitlab","hacktoberfest","semver"],"created_at":"2024-10-28T06:42:21.929Z","updated_at":"2026-01-20T22:01:59.055Z","avatar_url":"https://github.com/dex4er.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gitlab-ci-semver-labels\n\n[![GitHub](https://img.shields.io/github/v/tag/dex4er/gitlab-ci-semver-labels?label=GitHub)](https://github.com/dex4er/gitlab-ci-semver-labels)\n[![Snapshot](https://github.com/dex4er/gitlab-ci-semver-labels/actions/workflows/snapshot.yaml/badge.svg)](https://github.com/dex4er/gitlab-ci-semver-labels/actions/workflows/snapshot.yaml)\n[![Release](https://github.com/dex4er/gitlab-ci-semver-labels/actions/workflows/release.yaml/badge.svg)](https://github.com/dex4er/gitlab-ci-semver-labels/actions/workflows/release.yaml)\n[![Trunk Check](https://github.com/dex4er/gitlab-ci-semver-labels/actions/workflows/trunk.yaml/badge.svg)](https://github.com/dex4er/gitlab-ci-semver-labels/actions/workflows/trunk.yaml)\n[![Docker Image Version](https://img.shields.io/docker/v/dex4er/gitlab-ci-semver-labels?label=Docker\u0026logo=docker\u0026sort=semver)](https://hub.docker.com/r/dex4er/gitlab-ci-semver-labels)\n[![Amazon ECR Image Version](https://img.shields.io/docker/v/dex4er/gitlab-ci-semver-labels?label=Amazon%20ECR\u0026logo=Amazon+AWS\u0026sort=semver)](https://gallery.ecr.aws/dex4er/gitlab-ci-semver-labels)\n\nBump the semver for a Gitlab CI project based on merge request labels.\n\nIf no `current` command was used nor any of `bump` command then labels of the\nMerge Requests are taken either from `$CI_MERGE_REQUEST_LABELS` environment\nvariable or from details of the Merge Requests pointed by the commit message\nfrom `$CI_COMMIT_MESSAGE` environment variable.\n\nCommit message should contain the string `See merge request PROJECT!NUMBER`.\n\nTo fetch the details of the Merge Request the tool needs the Gitlab API token\nwith the `read_api` scope. The token is taken from the `$GITLAB_TOKEN`\nenvironment variable by default.\n\nVersions printed by this tool are normalized. It means that `v` prefix is\nalways trimmed from the output.\n\nThe best result is when merge trains are enabled in the merge options for the\nproject. In this case, it is possible to verify the bumped version before the\nactual merge is done.\n\n## Usage\n\n```sh\ngitlab-ci-semver-labels [command] [flags]\n```\n\n### Docker\n\nFrom DockerHub:\n\n```sh\ndocker run -it dex4er/gitlab-ci-semver-labels [command] [flags]\n```\n\nor from Amazon ECR Public:\n\n```sh\ndocker run -it public.ecr.aws/q8i3x1g6/gitlab-ci-semver-labels [command] [flags]\n```\n\nSupported tags:\n\n- vX.Y.Z-linux-amd64\n- vX.Y.Z-linux-arm64\n- vX.Y.Z\n- vX.Y\n- vX\n- latest\n\n### Available Commands\n\n```console\n  bump        Bump version\n  current     Show current version\n  help        Help about any command\n```\n\n#### bump\n\n```console\n  initial     Set to initial version without checking labels\n  major       Bump major version without checking labels\n  minor       Bump minor version without checking labels\n  patch       Bump patch version without checking labels\n```\n\n### Flags\n\n```console\n      --commit-message-regexp REGEXP     REGEXP for commit message after merged MR (default \"(?s)(?:^|\\\\n)See merge request (?:\\\\w[\\\\w.+/-]*)?!(\\\\d+)\")\n  -d, --dotenv-file FILE                 write dotenv format to FILE\n  -D, --dotenv-var NAME                  variable NAME in dotenv file (default \"VERSION\")\n  -f, --fail                             fail if merge request are not matched\n  -T, --fetch-tags                       fetch tags from git repo (default true)\n  -t, --gitlab-token-env VAR             name for environment VAR with Gitlab token (default \"GITLAB_TOKEN\")\n  -g, --gitlab-url URL                   URL of the Gitlab instance (default \"https://gitlab.com\")\n  -h, --help                             help for gitlab-ci-semver-labels\n      --initial-label-regexp REGEXP      REGEXP for initial release label (default \"(?i)initial.release|semver(.|::)initial\")\n  -V  --initial-version VERSION          initial VERSION for initial release (default \"0.0.0\")\n      --major-label-regexp REGEXP        REGEXP for major (breaking) release label (default \"(?i)(major|breaking).release|semver(.|::)(major|breaking)\")\n      --minor-label-regexp REGEXP        REGEXP for minor (feature) release label (default \"(?i)(minor|feature).release|semver(.|::)(minor|feature)\")\n      --patch-label-regexp REGEXP        REGEXP for patch (fix) release label (default \"(?i)(patch|fix).release|semver(.|::)(patch|fix)\")\n      --prerelease-label-regexp REGEXP   REGEXP for prerelease label (default \"(?i)pre.?release\")\n  -p, --project PROJECT                  PROJECT id or name (default $CI_PROJECT_ID)\n  -P, --prerelease                       bump version as prerelease\n  -r, --remote-name NAME                 NAME of git remote (default \"origin\")\n  -v, --version                          VERSION for gitlab-ci-semver-labels\n  -C, --work-tree DIR                    DIR to be used for git operations (default \".\")\n```\n\n### Configuration\n\nSome options can be read from the configuration file\n`.gitlab-ci-semver-labels.yml`:\n\n```yaml\ncommit-message-regexp: (?s)(?:^|\\n)See merge request (?:\\w[\\w.+/-]*)?!(\\d+)\ndotenv-file: \"\"\ndotenv-var: VERSION\nfail: false\nfetch-tags: true\ngitlab-token-env: GITLAB_TOKEN\ngitlab-url: https://gitlab.com\ninitial-label-regexp: (?i)initial.release|semver(.|::)initial\ninitial-version: 0.0.0\nmajor-label-regexp: (?i)(major|breaking).release|semver(.|::)(major|breaking)\nminor-label-regexp: (?i)(minor|feature).release|semver(.|::)(minor|feature)\npatch-label-regexp: (?i)(patch|fix).release|semver(.|::)(patch|fix)\nprerelease-label-regexp: (?i)pre.?release\nproject: dex4er/gitlab-ci-semver-labels\nremote-name: origin\nwork-tree: .\n```\n\n### Environment variables\n\nAny option might be overridden with an environment variable with the name the\nsame as an option with the prefix `GITLAB_CI_SEMVER_LABELS_` and an option name\nwith all capital letters with a dash character replaced with an underscore. Ie.:\n\nAdditionally, `$CI_PROJECT_ID` is used as a default `project` option value and\n`$CI_SERVER_URL` as a default `gitlab-url` option value.\n\nThe `GITLAB_CI_SEMVER_LABELS_LOG` environment variable changes log level for messages\ngenerated by this tool: `TRACE`, `DEBUG`, `WARNING` or `ERROR` (the default).\n\n## CI\n\nExample `.gitlab-ci.yml`:\n\n```yaml\nvariables:\n  DOCKER_IO: docker.io\n\nstages:\n  - semver\n  - release\n  - label\n\nsemver:validate:\n  stage: semver\n  rules:\n    - if: $CI_MERGE_REQUEST_LABELS =~ /semver::/ \u0026\u0026 $CI_MERGE_REQUEST_EVENT_TYPE == 'merge_train'\n  image:\n    name: $DOCKER_IO/dex4er/gitlab-ci-semver-labels\n    entrypoint: [\"\"]\n  variables:\n    GIT_DEPTH: 0\n  script:\n    - gitlab-ci-semver-labels current || true\n    - gitlab-ci-semver-labels bump --fail\n  cache: []\n\nsemver:bump:\n  stage: semver\n  rules:\n    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH \u0026\u0026 $CI_COMMIT_MESSAGE =~ /(^|\\n)See merge request (\\w[\\w.+\\/-]*)?!\\d+/s\n  image:\n    name: $DOCKER_IO/dex4er/gitlab-ci-semver-labels\n    entrypoint: [\"\"]\n  variables:\n    GIT_DEPTH: 0\n  script:\n    - gitlab-ci-semver-labels current || true\n    - gitlab-ci-semver-labels bump --dotenv-file=semver.env\n  artifacts:\n    reports:\n      dotenv: semver.env\n  cache: []\n\nrelease:\n  stage: release\n  needs:\n    - semver:bump\n  rules:\n    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH \u0026\u0026 $CI_COMMIT_MESSAGE =~ /(^|\\n)See merge request (\\w[\\w.+\\/-]*)?!\\d+/s\n  image: registry.gitlab.com/gitlab-org/release-cli\n  script:\n    - if [ -n \"$VERSION\" ]; then\n      release-cli create\n      --name \"v$VERSION\"\n      --description \"Automatic release by gitlab-ci-semver-labels\"\n      --tag-name \"v$VERSION\"\n      --ref $CI_COMMIT_SHA;\n      else\n      echo \"No new version. Release skipped.\";\n      fi\n  cache: []\n\nlabel:\n  stage: label\n  needs:\n    - release\n  rules:\n    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH \u0026\u0026 $CI_COMMIT_MESSAGE =~ /(^|\\n)See merge request (\\w[\\w.+\\/-]*)?!\\d+/s\n  image:\n    name: registry.gitlab.com/gitlab-org/cli:v1.35.0\n    entrypoint: [\"\"]\n  variables:\n    GITLAB_HOST: $CI_SERVER_URL\n  script:\n    - MR=$(echo \"$CI_COMMIT_MESSAGE\" | sed -n '/^See merge request [A-Za-z0-9.+\\/-]*![0-9][0-9]*$/s/^See merge request [A-Za-z0-9.+\\/-]*!\\([0-9][0-9]*\\)$/\\1/p');\n      if [ -n \"$VERSION\" ] \u0026\u0026 [ -n \"$MR\" ]; then\n      glab api -X PUT \"projects/:id/merge_requests/$MR\" --field \"add_labels=v::${VERSION#v}\" --silent;\n      else\n      echo \"No new version. Label skipped.\";\n      fi\n  cache: []\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdex4er%2Fgitlab-ci-semver-labels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdex4er%2Fgitlab-ci-semver-labels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdex4er%2Fgitlab-ci-semver-labels/lists"}