52 lines
1.9 KiB
YAML
52 lines
1.9 KiB
YAML
---
|
|
apiVersion: tekton.dev/v1beta1
|
|
kind: Task
|
|
metadata:
|
|
name: git-version
|
|
labels:
|
|
app.kubernetes.io/version: "0.1"
|
|
annotations:
|
|
tekton.dev/pipelines.minVersion: "0.12.0"
|
|
tekton.dev/displayName: "git version"
|
|
tekton.dev/categories: Git
|
|
tekton.dev/tags: git
|
|
tekton.dev/platforms: "linux/amd64"
|
|
spec:
|
|
description: >-
|
|
This task can be used to create a version from git history
|
|
params:
|
|
- name: gitversion-image
|
|
default: gittools/gitversion:6.0.0-alpine.3.18-7.0
|
|
description: The name of the toolbox image
|
|
type: string
|
|
- name: branch
|
|
type: string
|
|
results:
|
|
- description: The calculated git version you could use for git tagging e.g. "0.1.0-tektonize.1-188"
|
|
name: gitVersion
|
|
- description: A normalized version for use in container images e.g. "0.1.0-tektonize.1-188"
|
|
name: packageVersion
|
|
- name: shortSHA
|
|
steps:
|
|
- name: set-git-version
|
|
image: $(params.gitversion-image)
|
|
workingDir: $(workspaces.source.path)
|
|
script: |
|
|
#!/usr/bin/env ash
|
|
git switch $(params.branch)
|
|
ShortSha=$(/tools/dotnet-gitversion . /showvariable ShortSha)
|
|
echo -n "ShortSha: "
|
|
echo -n "${ShortSha}" | tee $(results.shortSHA.path)
|
|
echo
|
|
FullSemVer=$(/tools/dotnet-gitversion . /showvariable FullSemVer)
|
|
echo "FullSemVer: "
|
|
echo -n "${FullSemVer}" | tee $(results.gitVersion.path)
|
|
echo
|
|
# normalize a bit because
|
|
# image tags can only contain `abcdefghijklmnopqrstuvwxyz0123456789_-.ABCDEFGHIJKLMNOPQRSTUVWXYZ`
|
|
packageVersion=$(echo -n $FullSemVer | sed 's/[^-._0-9A-Za-z]/-/g'|sed 's/-/-beta./')
|
|
echo -n "packageVersion: "
|
|
echo -n "${packageVersion}" | tee $(results.packageVersion.path)
|
|
workspaces:
|
|
- name: source
|
|
description: A workspace that contains the fetched git repository to create a version for. |