@@ -4,7 +4,7 @@ name: CI (Build & Push Docker + Auto Release)
44on :
55 push :
66 branches : [ "main" ]
7- tags : [ "v*.*.*", "*.*.*" ] # supports v2.0.1 or 2.0.1
7+ tags : [ "v*.*.*", "*.*.*" ]
88 workflow_dispatch : {}
99
1010env :
1313 DOCKERFILE : ./Dockerfile
1414
1515permissions :
16- contents : write # needed to push tags & create releases
16+ contents : write
1717
1818jobs :
1919 build-and-push :
@@ -44,24 +44,18 @@ jobs:
4444 uses : docker/metadata-action@v5
4545 with :
4646 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47- # Only SemVer on tag events; latest/branch/sha on main pushes
47+ # 👇 build ONLY the right tags for each event type
4848 tags : |
4949 type=semver,pattern={{version}},enable=${{ github.ref_type == 'tag' }}
5050 type=raw,value=latest,enable=${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
5151 type=ref,event=branch,enable=${{ github.ref_type == 'branch' }}
52- type=sha,enable=${{ github.ref_type == 'branch' }}
5352 labels : |
5453 org.opencontainers.image.title=${{ github.event.repository.name }}
5554 org.opencontainers.image.source=${{ github.repository }}
5655 org.opencontainers.image.revision=${{ github.sha }}
5756
58- - name : Debug tags & labels
59- run : |
60- echo "TAGS:"
61- echo "${{ steps.meta.outputs.tags }}"
62- echo
63- echo "LABELS:"
64- echo "${{ steps.meta.outputs.labels }}"
57+ - name : Debug tags
58+ run : echo "${{ steps.meta.outputs.tags }}"
6559
6660 - name : Build & Push (linux/amd64 + linux/arm64)
6761 uses : docker/build-push-action@v6
8478 - name : Checkout
8579 uses : actions/checkout@v4
8680 with :
87- fetch-depth : 0 # need full history for tags
81+ fetch-depth : 0
8882
8983 - name : Bump patch version and create tag
9084 id : bump
9993 git config user.name "github-actions[bot]"
10094 git config user.email "github-actions[bot]@users.noreply.github.com"
10195 git tag -a "$NEW_TAG" -m "release $NEW_TAG"
102- git push origin "$NEW_TAG"
103- echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT
104-
105- - name : Create GitHub Release
106- uses : softprops/action-gh-release@v2
107- with :
108- tag_name : ${{ steps.bump.outputs.tag }}
109- name : Release ${{ steps.bump.outputs.tag }}
110- body : |
111- 🚀 Automated release from CI.
112- env :
113- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
96+ git push origin "$NEW_TAG"
0 commit comments