@@ -3,7 +3,6 @@ name: Delivery
33on :
44 push :
55 branches : [main]
6- tags : ['v*']
76 pull_request :
87 branches : [main]
98 workflow_dispatch :
@@ -21,11 +20,14 @@ jobs:
2120 steps :
2221 - name : Checkout
2322 uses : actions/checkout@v6
23+ with :
24+ fetch-depth : 0
2425
2526 - name : Select build profile
2627 id : config
2728 run : |
28- if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
29+ TAG=$(git tag --points-at HEAD | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
30+ if [[ -n "${TAG}" ]]; then
2931 echo "profile=release" >> "$GITHUB_OUTPUT"
3032 else
3133 echo "profile=edge" >> "$GITHUB_OUTPUT"
@@ -77,11 +79,14 @@ jobs:
7779 steps :
7880 - name : Checkout
7981 uses : actions/checkout@v6
82+ with :
83+ fetch-depth : 0
8084
8185 - name : Select build profile
8286 id : config
8387 run : |
84- if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
88+ TAG=$(git tag --points-at HEAD | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
89+ if [[ -n "${TAG}" ]]; then
8590 echo "profile=release" >> "$GITHUB_OUTPUT"
8691 else
8792 echo "profile=edge" >> "$GITHUB_OUTPUT"
@@ -114,16 +119,27 @@ jobs:
114119 runs-on : ubuntu-latest
115120 needs : [build-amd64, build-arm64]
116121 steps :
117- # No checkout needed: docker/metadata-action reads from the GitHub Actions context.
122+ - name : Checkout
123+ uses : actions/checkout@v6
124+ with :
125+ fetch-depth : 0
126+
127+ - name : Detect release tag on HEAD
128+ id : release
129+ run : |
130+ TAG=$(git tag --points-at HEAD | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
131+ echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
132+ echo "is_release=$([[ -n "${TAG}" ]] && echo true || echo false)" >> "$GITHUB_OUTPUT"
133+
118134 - name : Docker meta
119135 id : meta
120136 uses : docker/metadata-action@v6
121137 with :
122138 images : ghcr.io/${{ github.repository }}
123139 tags : |
124- type=semver,pattern={{version}},event= tag
125- type=semver,pattern={{major}}.{{minor}},event= tag
126- type=edge,enable=${{ !startsWith(github.ref, 'refs/tags/') }}
140+ type=semver,pattern={{version}},value=${{ steps.release.outputs. tag }},enable=${{ steps.release.outputs.is_release == 'true' }}
141+ type=semver,pattern={{major}}.{{minor}},value=${{ steps.release.outputs. tag }},enable=${{ steps.release.outputs.is_release == 'true' }}
142+ type=edge,enable=${{ steps.release.outputs.is_release != 'true' }}
127143 type=ref,event=pr
128144 type=ref,event=branch,enable=${{ github.event_name == 'workflow_dispatch' }}
129145
0 commit comments