diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml index 05a456ff5..8b4f41b14 100644 --- a/.github/workflows/publish-images.yml +++ b/.github/workflows/publish-images.yml @@ -39,6 +39,12 @@ jobs: grep -Fqx "## $version" CHANGELOG.md || { echo "CHANGELOG.md is missing ## $version" >&2; exit 1; } fi echo "version=$version" >> "$GITHUB_OUTPUT" + echo "image_tag=${version#v}" >> "$GITHUB_OUTPUT" + if [[ "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]]; then + echo "is_semver=true" >> "$GITHUB_OUTPUT" + else + echo "is_semver=false" >> "$GITHUB_OUTPUT" + fi echo "build_time=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT" - name: Set up QEMU @@ -61,7 +67,8 @@ jobs: images: ghcr.io/${{ github.repository_owner }}/${{ matrix.image }} tags: | type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} - type=semver,pattern={{version}} + type=raw,value=${{ steps.build-info.outputs.image_tag }},enable=${{ startsWith(github.ref, 'refs/tags/v') }} + type=semver,pattern={{version}},enable=${{ steps.build-info.outputs.is_semver == 'true' }} type=sha,prefix=sha- - name: Build and push image