Skip to content

Commit 9f887eb

Browse files
stevappleclaude
andauthored
fix(build): tag images by version and major.minor instead of latest (#632)
Every v* tag pushed :latest, so a patch released on an older line or a pre-release tag would move it backwards. Rather than making :latest smarter, drop it: before 1.0 every minor is allowed to break compatibility, so a floating latest silently carries consumers across compatibility boundaries. A moving {{major}}.{{minor}} tag lands exactly on that boundary in 0.x and serves the same purpose. Tags now come from docker/metadata-action with {{version}} and {{major}}.{{minor}}. flavor: latest=false is required because the action would otherwise add latest on its own, its default being latest=auto. Nothing has to consult the rest of the tag history: a patch published on an older line moves only its own line, and pre-releases only ever extend {{version}}, never a moving tag. The labels output is wired through as well, since org.opencontainers.image.source is what links the GHCR package back to this repository. Note that {{version}} strips the v prefix, so images are tagged :0.3.0 rather than :v0.3.0. No release has been cut since #631, so nothing already published is affected. Signed-off-by: YR Chen <stevapple@icloud.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent e1de618 commit 9f887eb

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

.github/workflows/release.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@ jobs:
153153
username: ${{ github.actor }}
154154
password: ${{ secrets.GITHUB_TOKEN }}
155155

156+
- name: Extract image metadata
157+
id: meta
158+
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
159+
with:
160+
images: ghcr.io/${{ github.repository }}
161+
flavor: latest=false
162+
tags: |
163+
type=semver,pattern={{version}}
164+
type=semver,pattern={{major}}.{{minor}}
165+
156166
- name: Build and push image
157167
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
158168
with:
@@ -163,9 +173,8 @@ jobs:
163173
build-args: |
164174
GITVERSION=${{ github.ref_name }}
165175
GITCOMMIT=${{ steps.vars.outputs.commit }}
166-
tags: |
167-
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
168-
ghcr.io/${{ github.repository }}:latest
176+
tags: ${{ steps.meta.outputs.tags }}
177+
labels: ${{ steps.meta.outputs.labels }}
169178

170179
create-release:
171180
needs: release

0 commit comments

Comments
 (0)