Skip to content

Commit fa69a14

Browse files
authored
Simplify Docker tag publishing workflow (#1333)
1 parent c9b6cbf commit fa69a14

1 file changed

Lines changed: 32 additions & 34 deletions

File tree

.github/workflows/ci.yml

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -231,31 +231,22 @@ jobs:
231231
strategy:
232232
fail-fast: false
233233
matrix:
234-
platform:
235-
- linux/amd64
236-
- linux/arm/v7
237-
- linux/arm64
238-
variant:
239-
- minimal
240-
- duckdb
241-
exclude:
242-
# DuckDB ODBC is not available for armv7
234+
include:
243235
- platform: linux/arm/v7
244-
variant: duckdb
245-
# This build is shared with the Hurl example jobs.
246-
- platform: linux/amd64
247236
variant: minimal
237+
tag_suffix: -linux-arm-v7
238+
- platform: linux/arm64
239+
variant: minimal
240+
tag_suffix: -linux-arm64
241+
- platform: linux/amd64
242+
variant: duckdb
243+
tag_suffix: -linux-amd64-duckdb
244+
- platform: linux/arm64
245+
variant: duckdb
246+
tag_suffix: -linux-arm64-duckdb
248247
steps:
249248
- name: Checkout
250249
uses: actions/checkout@v6
251-
- id: suffix
252-
name: Cache name suffix
253-
run: |
254-
suffix="-$(tr '/' '-' <<< "${{ matrix.platform }}")"
255-
if [[ "${{ matrix.variant }}" != "minimal" ]]; then
256-
suffix="${suffix}-${{ matrix.variant }}"
257-
fi
258-
echo "suffix=${suffix}" >> "$GITHUB_OUTPUT"
259250
- id: cache-scope
260251
name: Docker cache scope
261252
run: |
@@ -266,15 +257,15 @@ jobs:
266257
267258
recipe_hash="${{ hashFiles('Dockerfile', '.cargo/**', 'Cargo.toml', 'Cargo.lock', 'build.rs', 'scripts/**', 'sqlpage/**') }}"
268259
{
269-
echo "current=sqlpage-${ref_scope}${{ steps.suffix.outputs.suffix }}-${recipe_hash}"
270-
echo "main=sqlpage-main${{ steps.suffix.outputs.suffix }}-${recipe_hash}"
260+
echo "current=sqlpage-${ref_scope}${{ matrix.tag_suffix }}-${recipe_hash}"
261+
echo "main=sqlpage-main${{ matrix.tag_suffix }}-${recipe_hash}"
271262
} >> "$GITHUB_OUTPUT"
272263
- name: Docker meta
273264
id: meta
274265
uses: docker/metadata-action@v6
275266
with:
276267
images: ${{ env.REGISTRY_IMAGE }}
277-
flavor: suffix=${{ steps.suffix.outputs.suffix }}
268+
flavor: suffix=${{ matrix.tag_suffix }}
278269
labels: |
279270
org.opencontainers.image.created=1970-01-01T00:00:00Z
280271
- name: Set up QEMU
@@ -303,7 +294,7 @@ jobs:
303294
cache-from: |
304295
type=gha,scope=${{ steps.cache-scope.outputs.current }}
305296
type=gha,scope=${{ steps.cache-scope.outputs.main }}
306-
type=registry,ref=${{ env.REGISTRY_IMAGE }}:main${{ steps.suffix.outputs.suffix }}
297+
type=registry,ref=${{ env.REGISTRY_IMAGE }}:main${{ matrix.tag_suffix }}
307298
cache-to: type=gha,scope=${{ steps.cache-scope.outputs.current }},mode=max
308299
- name: Export digest
309300
if: github.event_name != 'pull_request'
@@ -315,7 +306,7 @@ jobs:
315306
uses: actions/upload-artifact@v7
316307
if: github.event_name != 'pull_request'
317308
with:
318-
name: digests-${{ matrix.variant }}${{ steps.suffix.outputs.suffix }}
309+
name: digests-${{ matrix.variant }}${{ matrix.tag_suffix }}
319310
path: /tmp/digests/*
320311
if-no-files-found: error
321312
retention-days: 1
@@ -520,22 +511,29 @@ jobs:
520511
path: /tmp/digests
521512
- name: Set up Docker Buildx
522513
uses: docker/setup-buildx-action@v4
523-
- name: Docker meta
524-
id: meta
525-
uses: docker/metadata-action@v6
526-
with:
527-
images: ${{ env.REGISTRY_IMAGE }}
528-
flavor: suffix=${{ matrix.variant != 'minimal' && format('-{0}', matrix.variant) || '' }},onlatest=true
529514
- name: Login to Docker Hub
530515
uses: docker/login-action@v4
531516
with:
532517
username: ${{ env.REGISTRY_USERNAME }}
533518
password: ${{ secrets.DOCKERHUB_TOKEN }}
534519
- name: Create manifest list and push
535520
working-directory: /tmp/digests
521+
env:
522+
TAG_SUFFIX: ${{ matrix.variant != 'minimal' && format('-{0}', matrix.variant) || '' }}
536523
run: |
537-
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
538-
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
524+
tags=(-t "${REGISTRY_IMAGE}:${GITHUB_REF_NAME}${TAG_SUFFIX}")
525+
if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
526+
tags+=(-t "${REGISTRY_IMAGE}:latest${TAG_SUFFIX}")
527+
fi
528+
shopt -s nullglob
529+
sources=()
530+
for digest in *; do
531+
sources+=("${REGISTRY_IMAGE}@sha256:${digest}")
532+
done
533+
((${#sources[@]} > 0))
534+
docker buildx imagetools create "${tags[@]}" "${sources[@]}"
539535
- name: Inspect image
536+
env:
537+
TAG_SUFFIX: ${{ matrix.variant != 'minimal' && format('-{0}', matrix.variant) || '' }}
540538
run: |
541-
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
539+
docker buildx imagetools inspect "${REGISTRY_IMAGE}:${GITHUB_REF_NAME}${TAG_SUFFIX}"

0 commit comments

Comments
 (0)