Skip to content

Commit 0f02da3

Browse files
ci: address review feedback on generate-tag.sh
- Remove unused IMAGE_URL parameter - Normalize dates to UTC (TZ=UTC + --date=format-local) - Remove silent error suppression (fail loud > wrong tag) - Update pipeline task to match new script interface Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 20c5f4b commit 0f02da3

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

.tekton/pipelines/push.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,14 +538,55 @@ spec:
538538
operator: in
539539
values:
540540
- "false"
541+
- name: generate-image-tag
542+
params:
543+
- name: SOURCE_ARTIFACT
544+
value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
545+
runAfter:
546+
- build-image-index
547+
taskSpec:
548+
params:
549+
- name: SOURCE_ARTIFACT
550+
type: string
551+
results:
552+
- name: VERSION_TAG
553+
type: string
554+
volumes:
555+
- name: workdir
556+
emptyDir: {}
557+
steps:
558+
- name: use-trusted-artifact
559+
image: quay.io/konflux-ci/build-trusted-artifacts:latest@sha256:15d7dc86012e41b10d1eb37679ec03ee75c96436224fadd0938a49dc537aa4ad
560+
args:
561+
- use
562+
- $(params.SOURCE_ARTIFACT)=/var/workdir/source
563+
volumeMounts:
564+
- mountPath: /var/workdir
565+
name: workdir
566+
- name: generate-tag
567+
image: quay.io/konflux-ci/task-runner:1.4.1@sha256:d9feec6f2ce9b10cfb76b45ea14f83b5ed9f231de7d6083291550aebe8eb09ea
568+
volumeMounts:
569+
- mountPath: /var/workdir
570+
name: workdir
571+
script: |
572+
#!/usr/bin/env bash
573+
set -euo pipefail
574+
VERSION_TAG=$(bash /var/workdir/source/scripts/generate-tag.sh /var/workdir/source)
575+
echo -n "${VERSION_TAG}" > /tekton/results/VERSION_TAG
576+
echo "Generated version tag: ${VERSION_TAG}"
541577
- name: apply-tags
542578
params:
543579
- name: IMAGE_URL
544580
value: $(tasks.build-image-index.results.IMAGE_URL)
545581
- name: IMAGE_DIGEST
546582
value: $(tasks.build-image-index.results.IMAGE_DIGEST)
583+
- name: ADDITIONAL_TAGS
584+
value:
585+
- $(tasks.generate-image-tag.results.VERSION_TAG)
586+
- latest
547587
runAfter:
548588
- build-image-index
589+
- generate-image-tag
549590
taskRef:
550591
params:
551592
- name: name

scripts/generate-tag.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SOURCE_DIR="${1:-.}"
6+
MAJOR=1
7+
8+
COMMIT_DATE=$(TZ=UTC git -C "${SOURCE_DIR}" log -1 --format="%ad" --date=format-local:"%Y%m%d" HEAD)
9+
# Count commits on the same day that are ancestors of HEAD (i.e., came before it).
10+
# This gives a deterministic, sequential build number from git history — no registry access needed.
11+
BUILD_NUM=$(TZ=UTC git -C "${SOURCE_DIR}" log HEAD^ --format="%ad" --date=format-local:"%Y%m%d" \
12+
| grep -c "^${COMMIT_DATE}$")
13+
14+
echo -n "${MAJOR}.${COMMIT_DATE}.${BUILD_NUM}"

0 commit comments

Comments
 (0)