Skip to content

Conversation

@SuperQ
Copy link
Member

@SuperQ SuperQ commented Apr 9, 2025

Check the current tag against the list of all tags to make sure that it is the actual latest tag before attempting to publish the container latest tag. This avoids updating the latest tag when pushing bug fixes to older release branchs.

Fixes: prometheus/prometheus#16238

Check the current tag against the list of all tags to make sure that it
is the actual latest tag before attempting to publish the container
`latest` tag. This avoids updating the `latest` tag when pushing bug
fixes to older release branchs.

Fixes: prometheus/prometheus#16238

Signed-off-by: SuperQ <[email protected]>
Copy link
Member

@machine424 machine424 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, we'll end up tweaking the CI after all :)
left some comments

shell: bash
- run: |
current_tag=${GITHUB_REF#refs/*/}
latest_tag=$(git tag --sort=v:refname | tail -n 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe we could log this and current_tag for better visibility.

make docker-manifest DOCKER_IMAGE_TAG="latest" DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker-publish DOCKER_IMAGE_TAG="$current_tag" DOCKER_REPO="${reg_repo}"
make docker-manifest DOCKER_IMAGE_TAG="$current_tag" DOCKER_REPO="${reg_repo}"
if [[ "${current_tag}" == "${latest_tag}" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trying this out:

$ git tag --sort=v:refname | tail -n 3
v3.2.1
v3.3.0-rc.0
v3.3.0-rc.1

so if we ship v3.2.2 now, latest will not get applied because of the 3.3 RCs

I'll try to sell it again, how about using docker/metadata-actio to take care of that?
I'm not too familiar with the action, but AI suggested:

      # Use docker/metadata-action to extract version metadata and generate tags
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: yourdockerhubusername/yourimage
          tags: |
            type=semver,pattern={{major}}.{{minor}}.{{patch}},default=true
            type=semver,pattern=latest,default=true,when=!pre
            type=semver,pattern=v{{ major }},when=!pre
            type=semver,pattern=v{{ major }}.{{ minor }},when=!pre

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, let me look at docker/metadata-action.

@dpw13
Copy link

dpw13 commented Jul 5, 2025

This bit me again today. @SuperQ are you still able to look at docker/metadata-action and close this out? If you're not, let us know so somebody else can take this issue and fix it.

@bboreham
Copy link
Member

bboreham commented Sep 9, 2025

Hi, this came up in the Prometheus bug-scrub; @dpw13 are you able to pick this up, maybe make a new PR?

@dpw13
Copy link

dpw13 commented Sep 9, 2025

Hi, this came up in the Prometheus bug-scrub; @dpw13 are you able to pick this up, maybe make a new PR?

I will try to dedicate some time to this this week! I'll open a separate PR once I have an idea what needs to happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not override "latest" docker flag with bug fix releases

5 participants