Skip to content

Commit 7b4773a

Browse files
dpark01claude
andcommitted
Strip 'v' prefix from Docker image version tags
When releasing v3.0.1, Docker images were incorrectly tagged as v3.0.1-core instead of 3.0.1-core. This fixes the issue by: 1. Adding 'v' prefix stripping to the image-tag-prefix computation 2. Using image-tag-prefix consistently in all version tag creation steps instead of github.ref_name directly 3. Simplifying the deploy-to-quay logic to use the same prefix This follows DRY principles by centralizing the version tag sanitization in one place (get-version job) rather than repeating it in 8 different locations. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 52542de commit 7b4773a

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

.github/workflows/docker.yml

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ jobs:
123123
else
124124
# For branches/tags, replace "/" with "-" to create valid Docker tags
125125
PREFIX=$(echo "${{ github.ref_name }}" | sed 's|/|-|g')
126+
# Strip leading 'v' for version tags (e.g., v3.0.1 -> 3.0.1)
127+
PREFIX=${PREFIX#v}
126128
fi
127129
echo "prefix=${PREFIX}" >> $GITHUB_OUTPUT
128130
echo "Image tag prefix: ${PREFIX}"
@@ -259,8 +261,8 @@ jobs:
259261
- name: Create version tags
260262
if: github.ref_type == 'tag'
261263
run: |
262-
VERSION="${{ github.ref_name }}"
263-
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^v?([0-9]+\.[0-9]+).*/\1/')
264+
VERSION="${{ needs.get-version.outputs.image-tag-prefix }}"
265+
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
264266
265267
# Create version tag
266268
docker buildx imagetools create \
@@ -420,8 +422,8 @@ jobs:
420422
- name: Create version tags
421423
if: github.ref_type == 'tag'
422424
run: |
423-
VERSION="${{ github.ref_name }}"
424-
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^v?([0-9]+\.[0-9]+).*/\1/')
425+
VERSION="${{ needs.get-version.outputs.image-tag-prefix }}"
426+
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
425427
426428
docker buildx imagetools create \
427429
--annotation "index:org.opencontainers.image.source=https://github.com/broadinstitute/viral-ngs" \
@@ -579,8 +581,8 @@ jobs:
579581
- name: Create version tags
580582
if: github.ref_type == 'tag'
581583
run: |
582-
VERSION="${{ github.ref_name }}"
583-
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^v?([0-9]+\.[0-9]+).*/\1/')
584+
VERSION="${{ needs.get-version.outputs.image-tag-prefix }}"
585+
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
584586
585587
docker buildx imagetools create \
586588
--annotation "index:org.opencontainers.image.source=https://github.com/broadinstitute/viral-ngs" \
@@ -738,8 +740,8 @@ jobs:
738740
- name: Create version tags
739741
if: github.ref_type == 'tag'
740742
run: |
741-
VERSION="${{ github.ref_name }}"
742-
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^v?([0-9]+\.[0-9]+).*/\1/')
743+
VERSION="${{ needs.get-version.outputs.image-tag-prefix }}"
744+
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
743745
744746
docker buildx imagetools create \
745747
--annotation "index:org.opencontainers.image.source=https://github.com/broadinstitute/viral-ngs" \
@@ -897,8 +899,8 @@ jobs:
897899
- name: Create version tags
898900
if: github.ref_type == 'tag'
899901
run: |
900-
VERSION="${{ github.ref_name }}"
901-
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^v?([0-9]+\.[0-9]+).*/\1/')
902+
VERSION="${{ needs.get-version.outputs.image-tag-prefix }}"
903+
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
902904
903905
docker buildx imagetools create \
904906
--annotation "index:org.opencontainers.image.source=https://github.com/broadinstitute/viral-ngs" \
@@ -1050,8 +1052,8 @@ jobs:
10501052
- name: Create version tags
10511053
if: github.ref_type == 'tag'
10521054
run: |
1053-
VERSION="${{ github.ref_name }}"
1054-
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^v?([0-9]+\.[0-9]+).*/\1/')
1055+
VERSION="${{ needs.get-version.outputs.image-tag-prefix }}"
1056+
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
10551057
10561058
docker buildx imagetools create \
10571059
--annotation "index:org.opencontainers.image.source=https://github.com/broadinstitute/viral-ngs" \
@@ -1577,20 +1579,17 @@ jobs:
15771579
SUFFIX="-${FLAVOR}"
15781580
fi
15791581
1580-
# Build the branch/tag-based tag
1582+
# Use image-tag-prefix which handles both branches and version tags
1583+
# (strips 'v' prefix from version tags, sanitizes '/' in branch names)
1584+
TAG_PREFIX="${{ needs.get-version.outputs.image-tag-prefix }}"
1585+
echo "src_tag=${TAG_PREFIX}${SUFFIX}" >> $GITHUB_OUTPUT
1586+
echo "dest_tags=${TAG_PREFIX}${SUFFIX}" >> $GITHUB_OUTPUT
1587+
1588+
# For version tags, also create major.minor tag
15811589
if [[ "${{ github.ref_type }}" == "tag" ]]; then
1582-
# Version tag: copy as version tag
1583-
VERSION="${{ github.ref_name }}"
1584-
echo "src_tag=${VERSION}${SUFFIX}" >> $GITHUB_OUTPUT
1585-
echo "dest_tags=${VERSION}${SUFFIX}" >> $GITHUB_OUTPUT
1586-
# Also create major.minor tag
1587-
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^v?([0-9]+\.[0-9]+).*/\1/')
1590+
MAJOR_MINOR=$(echo "$TAG_PREFIX" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
15881591
echo "extra_dest_tag=${MAJOR_MINOR}${SUFFIX}" >> $GITHUB_OUTPUT
15891592
else
1590-
# Branch: copy as branch tag
1591-
BRANCH="${{ needs.get-version.outputs.image-tag-prefix }}"
1592-
echo "src_tag=${BRANCH}${SUFFIX}" >> $GITHUB_OUTPUT
1593-
echo "dest_tags=${BRANCH}${SUFFIX}" >> $GITHUB_OUTPUT
15941593
echo "extra_dest_tag=" >> $GITHUB_OUTPUT
15951594
fi
15961595

0 commit comments

Comments
 (0)