|
|
|
@ -18,11 +18,13 @@ spec:
|
|
|
|
|
description: The name of the job to report to gitea
|
|
|
|
|
type: string
|
|
|
|
|
tasks:
|
|
|
|
|
- name: get-time
|
|
|
|
|
- name: calculate-tag
|
|
|
|
|
runAfter:
|
|
|
|
|
- report-pending
|
|
|
|
|
taskSpec:
|
|
|
|
|
metadata: {}
|
|
|
|
|
stepTemplate:
|
|
|
|
|
image: alpine:3.18
|
|
|
|
|
image: alpine:3.19
|
|
|
|
|
name: ""
|
|
|
|
|
resources:
|
|
|
|
|
requests:
|
|
|
|
@ -30,15 +32,33 @@ spec:
|
|
|
|
|
memory: 600Mi
|
|
|
|
|
workingDir: /workspace/source
|
|
|
|
|
results:
|
|
|
|
|
- name: unix-time
|
|
|
|
|
description: The current date in unix timestamp format
|
|
|
|
|
- name: tag
|
|
|
|
|
description: The tag to use for the docker container
|
|
|
|
|
steps:
|
|
|
|
|
- image: alpine:3.18
|
|
|
|
|
name: get-time-step
|
|
|
|
|
- image: alpine/git:2.43.0
|
|
|
|
|
name: calculate-tag
|
|
|
|
|
script: |
|
|
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
echo -n "$(date +%s)" | tee $(results.unix-time.path)
|
|
|
|
|
cd $(workspaces.repo.path)
|
|
|
|
|
git fetch --tags
|
|
|
|
|
current_tag=$(git tag --points-at HEAD --list 'v*.*.*')
|
|
|
|
|
if [ -z "$current_tag" ]; then
|
|
|
|
|
prev_tag=$(git tag --list 'v*.*.*' | sort -V -r | head -n 1)
|
|
|
|
|
if [ -n "$prev_tag" ]; then
|
|
|
|
|
last_bit=$(echo "$prev_tag" | cut -d '.' -f 3)
|
|
|
|
|
incremented=$((last_bit + 1))
|
|
|
|
|
prefix=$(echo "$prev_tag" | grep -oE 'v[0-9]*\.[0-9]*\.')
|
|
|
|
|
final_tag="${prefix}${incremented}"
|
|
|
|
|
else
|
|
|
|
|
final_tag="v0.0.1"
|
|
|
|
|
fi
|
|
|
|
|
echo -n "${final_tag}" | tee $(results.tag.path)
|
|
|
|
|
git tag "${final_tag}"
|
|
|
|
|
echo git push origin "${final_tag}"
|
|
|
|
|
else
|
|
|
|
|
echo -n "${current_tag}" | tee $(results.tag.path)
|
|
|
|
|
fi
|
|
|
|
|
- name: report-pending
|
|
|
|
|
taskRef:
|
|
|
|
|
resolver: git
|
|
|
|
|