1- # .github/workflows/ci.yml
21name : CI (Build & Push Docker + Auto Release)
32
43on :
@@ -17,7 +16,6 @@ permissions:
1716
1817jobs :
1918 build-and-push :
20- name : Build & Push multi-arch image to Docker Hub
2119 runs-on : ubuntu-latest
2220 steps :
2321 - name : Checkout
2624 - name : Set up QEMU
2725 uses : docker/setup-qemu-action@v3
2826
29- - name : Set up Docker Buildx
27+ - name : Set up Buildx
3028 uses : docker/setup-buildx-action@v3
3129
3230 - name : Log in to Docker Hub
@@ -44,20 +42,21 @@ jobs:
4442 uses : docker/metadata-action@v5
4543 with :
4644 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47- # 👇 build ONLY the right tags for each event type
45+ # 👉 Only semver tags when triggered by a tag event
4846 tags : |
49- type=semver,pattern={{version}},enable=${{ github.ref_type == 'tag' }}
50- type=raw,value=latest,enable=${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
51- type=ref,event=branch,enable=${{ github.ref_type == 'branch' }}
47+ type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
48+ type=raw,value=latest,enable=${{ github.ref_name == 'main' && !startsWith(github.ref, 'refs/tags/') }}
49+ type=ref,event=branch,enable=${{ !startsWith(github.ref, 'refs/tags/') }}
50+ type=sha,enable=${{ !startsWith(github.ref, 'refs/tags/') }}
5251 labels : |
5352 org.opencontainers.image.title=${{ github.event.repository.name }}
5453 org.opencontainers.image.source=${{ github.repository }}
5554 org.opencontainers.image.revision=${{ github.sha }}
5655
5756 - name : Debug tags
58- run : echo "${{ steps.meta.outputs.tags }}"
57+ run : echo "→ ${{ steps.meta.outputs.tags }}"
5958
60- - name : Build & Push (linux/amd64 + linux/arm64)
59+ - name : Build & Push multi-arch
6160 uses : docker/build-push-action@v6
6261 with :
6362 context : .
7574 if : contains(github.event.head_commit.message, '#release')
7675 runs-on : ubuntu-latest
7776 steps :
78- - name : Checkout
79- uses : actions/checkout@v4
77+ - uses : actions/checkout@v4
8078 with :
8179 fetch-depth : 0
8280
8583 run : |
8684 set -e
8785 LAST=$(git tag -l 'v*' --sort=-v:refname | head -n1)
88- if [ -z "$LAST" ]; then LAST="v0.0.0"; fi
86+ [ -z "$LAST" ] && LAST="v0.0.0"
8987 VER=${LAST#v}
9088 IFS='.' read -r MA MI PA <<<"$VER"
9189 NEW_TAG="v$MA.$MI.$((PA+1))"
0 commit comments