fix: address prerelease workflow review issues

- Remove stale mauriceboe/nomad tags from docker-dev.yml
- Fix APP_VERSION empty string fallback (?? -> ||)
- Fix compareVersions to handle -pre.N suffixes correctly
- Use highest existing N instead of tag count to avoid collision after cleanup
- Add cleanup step to keep only last 5 prerelease tags per base version
This commit is contained in:
jubnl
2026-04-12 16:39:42 +02:00
parent e1a7558647
commit e198791139
2 changed files with 38 additions and 11 deletions
+21 -6
View File
@@ -54,9 +54,9 @@ jobs:
fi
echo "Target: $TARGET"
# Count existing prerelease tags for this target and increment
N=$(git tag -l "v${TARGET}-pre.*" | wc -l)
N=$((N + 1))
# Find the highest existing prerelease N for this target and increment
LAST_N=$(git tag -l "v${TARGET}-pre.*" | sed 's/.*-pre\.//' | sort -n | tail -1)
N=$(( ${LAST_N:-0} + 1 ))
NEW_VERSION="${TARGET}-pre.${N}"
echo "VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
@@ -151,10 +151,25 @@ jobs:
-t mauriceboe/trek:latest-pre \
-t mauriceboe/trek:$MAJOR_TAG \
-t mauriceboe/trek:$VERSION \
-t mauriceboe/nomad:latest-pre \
-t mauriceboe/nomad:$MAJOR_TAG \
-t mauriceboe/nomad:$VERSION \
"${digests[@]}"
- name: Inspect manifest
run: docker buildx imagetools inspect mauriceboe/trek:latest-pre
- name: Clean up old prerelease tags
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
KEEP=5
VERSION=${{ needs.version-bump.outputs.version }}
BASE_VERSION="$(echo "$VERSION" | sed 's/-pre\..*//')"
git fetch --tags
mapfile -t ALL_TAGS < <(git tag -l "v${BASE_VERSION}-pre.*" | sort -t. -k4 -n)
TOTAL=${#ALL_TAGS[@]}
DELETE_COUNT=$((TOTAL - KEEP))
if [ "$DELETE_COUNT" -gt 0 ]; then
for TAG in "${ALL_TAGS[@]:0:$DELETE_COUNT}"; do
echo "Deleting old prerelease tag: $TAG"
git push origin --delete "$TAG"
done
fi