Git Tag

kind: gittag

sourceconditiontarget

source

The Git Tag "source" retrieves the latest git Tag matching a pattern.

condition

The Git Tag "condition" tests if git Tag matching a pattern exist.

target

The Git Tag "condition" ensures a git Tag matching a pattern exist otherwise it creates it.

Parameter

The gittag resource is a resource designed to be used with the scmID

NameRequiredDefaultDescription

path

-

[S,C,T]Define the git directory path, not compatible with scmID

versionFilter

Provide version filtering information

versionFilter.kind

"latest"

VersionFilter.kind accept on of the following values: ["semver","latest","regex"]

versionFilter.pattern

The default pattern value depends on the version kind

message

"Generated by updatecli"

[T] Defines the tag message

Example

updatecli.yaml
---
title: "Test new gitTag resource"

scms:
  gitExample:
    kind: "git"
    spec:
        url: "git@github.com:updatecli/updatecli.git"
        branch: "main"
  githubExample:
    kind: "github"
    spec:
        user: "updatecli-bot"
        email: "updatecli@example.com"
        owner: "updatecli"
        repository: "updatecli"
        token: '{{ requiredEnv "GITHUB_TOKEN" }}'
        username: "john"
        branch: "main"
sources:
  gitExample1:
    name: "Get Latest updatecli test"
    kind: gitTag
    scmID: gitExample
    spec:

  gitExample2: # Without scmID
    name: Get Latest updatecli test
    kind: gitTag
    spec:
      path: "./git_repository_path/"

  githubSemver:
    name: Get Latest updatecli test
    kind: gitTag
    scmID: githubExample
    spec:
      versionFilter:
        kind: semver
        pattern: "~0.1"
  githubRegex:
    name: Get Latest updatecli test
    kind: gitTag
    scmID: githubExample
    spec:
      versionFilter:
        kind: regex
        pattern: "v0.*"
conditions:
  gitRegex:
    name: Test Get Latest updatecli test
    disablesourceinput: true
    kind: gitTag
    scmID: gitExample
    spec:
      versionFilter:
        pattern: "v0.1.2"
targets:
  github:
    sourceID: githubRegex
    name: Publish tag with -github
    scmID: githubExample
    kind: gitTag
    transformers:
      - addSuffix: "-github"
  git:
    scmID: gitExample
    sourceID: githubRegex
    name: Publish tag with -git
    kind: gitTag
    transformers:
      - addSuffix: "-git"

VersionFilter

versionFilter allows to specify the kind of version retrieved from a resource and its version pattern. Default value is "latest" as we want to retrieve the newest version from a resource.

latest

If kind is set to latest then no need to specify the patter as we gonna retrieve the newest version from the resource.

Example
sources:
  kubectl:
    kind: githubRelease
    spec:
      owner: "kubernetes"
      repository: "kubectl"
      token: "{{ requiredEnv .github.token }}"
      username: "john"
      versionFilter:
        kind: latest
    transformers:
      - trimPrefix: "kubernetes-"

Return the latest Github release and remove "kubernetes-" from it.

regex

If versionFilter.kind is set to regex then we can use versionFilter.pattern to specify a regular expression to return the newest version returned from a resource matching the regex If no versionFilter.pattern is provided then it uses '.*' which return the newest version

sources:
  kubectl:
    kind: githubRelease
    spec:
      owner: "kubernetes"
      repository: "kubectl"
      token: "{{ requiredEnv .github.token }}"
      username: "john"
      versionFilter:
        kind: regex
        pattern: "kubernetes-1.(\d*).(\d*)$"
    transformers:
      - trimPrefix: "kubernetes-"

⇒ Return the newest kubectl version matching pattern "kubernetes-1.(\d*).(\d*)$" and remove "kubernetes-" from it

semver

If versionFilter.kind is set to semver then we can use versionFilter.pattern to specify version pattern as explained here. In the process we also sort. If no versionFilter.pattern is provided then it fallback to '*' which return the newest version. If a version doesn’t respect semantic versioning, then it’s not the value is just ignored.

Remark

In the process we drop any characters not respecting semantic version like in this version "v1.0.0", we drop the "v" but we can added it back using transformers.

example
  jenkins-wiki-exporter:
    kind: githubRelease
    spec:
      owner: "jenkins-infra"
      repository: "jenkins-wiki-exporter"
      token: "{{ requiredEnv .github.token }}"
      username: "john"
      versionFilter:
        kind: semver
        pattern: "~1.10"

⇒ Return the version "v1.10.3"

Edit this page on GitHub