👷 Use only the closest tag in the build key

The full `git describe` output is not stable across checkouts: the
length of its -g<sha> suffix depends on the local object count, so
build-bundle and build-docker could compute different keys for the same
commit on different runner workspaces. The sha already pins the commit,
so the closest tag is enough to tell versions apart.

Signed-off-by: David Barragán Merino <david.barragan@kaleidos.net>
This commit is contained in:
David Barragán Merino 2026-10-26 20:25:48 +01:00 committed by David Barragán Merino
parent cf19d7f870
commit 4b13562d02
2 changed files with 9 additions and 4 deletions

View File

@ -80,13 +80,17 @@ jobs:
env:
GH_REF: ${{ inputs.gh_ref || github.ref_name }}
run: |
# Same command the build uses to stamp version.txt, so the key
# always matches what ends up inside the bundle.
# Same command the build uses to stamp version.txt.
BUNDLE_VERSION=$(./manage.sh version)
SHORT_SHA=$(git rev-parse --short=12 HEAD)
# The key takes only the closest tag (--abbrev=0): the sha already
# pins the commit, and the full describe output is not stable
# across checkouts (its -g<sha> suffix length depends on the
# local object count). Must match build-docker.yml.
VERSION_TAG=$(git describe --tags --match '*.*.*' --abbrev=0)
echo "gh_ref=$GH_REF" >> $GITHUB_OUTPUT
echo "bundle_version=$BUNDLE_VERSION" >> $GITHUB_OUTPUT
echo "build_key=sha-${SHORT_SHA}-${BUNDLE_VERSION}" >> $GITHUB_OUTPUT
echo "build_key=sha-${SHORT_SHA}-${VERSION_TAG}" >> $GITHUB_OUTPUT
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "commit_title=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT

View File

@ -109,11 +109,12 @@ jobs:
# Must match the key computed by build-bundle.yml.
BUNDLE_VERSION=$(./manage.sh version)
SHORT_SHA=$(git rev-parse --short=12 HEAD)
VERSION_TAG=$(git describe --tags --match '*.*.*' --abbrev=0)
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
echo "commit_title=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
echo "bundle_version=$BUNDLE_VERSION" >> $GITHUB_OUTPUT
echo "build_key=sha-${SHORT_SHA}-${BUNDLE_VERSION}" >> $GITHUB_OUTPUT
echo "build_key=sha-${SHORT_SHA}-${VERSION_TAG}" >> $GITHUB_OUTPUT
# The image set is a single block, so a single set-level check is
# enough: `promote` drops a marker object in S3 only after every