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

NameRequiredDefaultDescription

path

-

[S,C,T]Define the git directory path

versionFilter

[S,C] Define the tag "version" pattern

message

"Generated by updatecli"

[T] Defines the tag message

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"
      version: "~1.10"
      versioning:
        kind: semver
    transformers:
      - addPrefix: "v"

⇒ Return the version "v1.10.3"

Example

updatecli.yaml
title: "Test new gitTag resource"
sources:
  git:
    name: Get Latest updatecli test
    kind: gitTag
    scm:
      git:
        url: "git@github.com:updatecli/updatecli.git"
        branch: "main"
  githubRegex:
    name: Get Latest updatecli test
    kind: gitTag
    spec:
      versionFilter:
        kind: semver
        pattern: "~0.1"
    scm:
      github:
        user: "{{ .github.user }}"
        email: "{{ .github.email }}"
        owner: "updatecli"
        repository: "updatecli"
        token: "{{ requiredEnv .github.token }}"
        username: "{{ .github.username }}"
        branch: "main"
conditions:
  gitRegex:
    sourceID: default
    name: Test Get Latest updatecli test
    kind: gitTag
    spec:
      versionFilter:
        pattern: "v0.1.2"
    scm:
      git:
        url: "git@github.com:updatecli/updatecli.git"
        branch: "main"
  githubRegex:
    sourceID: default
    name: Test Get Latest updatecli test
    kind: gitTag
    spec:
      versionFilter:
        pattern: "v0.1.2"
    scm:
      github:
        user: "{{ .github.user }}"
        email: "{{ .github.email }}"
        owner: "updatecli"
        repository: "updatecli"
        token: "{{ requiredEnv .github.token }}"
        username: "{{ .github.username }}"
        branch: "main"
targets:
  github:
    sourceID: git
    name: Publish tag with -github
    kind: gitTag
    transformers:
      - addSuffix: "-github"
    scm:
      github:
        user: "{{ .github.user }}"
        email: "{{ .github.email }}"
        owner: "olblak"
        repository: "nocode"
        token: "{{ requiredEnv .github.token }}"
        username: "{{ .github.username }}"
        branch: "master"
  git:
    sourceID: githubRegex
    name: Publish tag with -git
    kind: gitTag
    transformers:
      - addSuffix: "-git"
    scm:
      git:
        url: "git@github.com:olblak/nocode.git"
        branch: "master"

Edit this page on GitHub