Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Make latest tag point to latest release and not a dev build #556

Closed
Huskydog9988 opened this issue Aug 3, 2021 · 11 comments
Assignees

Comments

@Huskydog9988
Copy link

What's the feature? 🧐

Make the latest tag in docker point to the latest release instead of a dev build.

  • Allows the user to just select the image, and know they are getting something stable
  • Doesn't require the user to seek out the latest version number to know they are running the latest and greatest
  • Follows the normal docker tag convention
    • This being that latest stable release is found on the latest tag, and dev builds on something like the dev tag
  • Falls in like with the provided run command as that points to specific version, just the latest dev build
  • Makes setup much easier as people don't have to painfully realize they are running experimental software

Optional extra information 🚀

  • I think this has been presented before but I couldn't that if it is the case
@qdm12
Copy link
Owner

qdm12 commented Aug 3, 2021

Hey nice suggestion.

Although, this is going to sound totally selfish... but I CRAVE user feedback!

There are so many aspects/features and different vpn providers, I can't (even with more tests) possibly ensure by myself that everything works.

I also doubt anyone would use the :dev image really.

I'm doing my best making sure :latest works through tests and by running it myself with Mullvad.

So far, I use :latest to know when it's stable to do releases actually. I do releases once:

  • latest has been out for a few days without changes and reported bug
  • or before pushing big error prone changes to master

So, yes the user run experimental code, but that feels to me like a critical piece to have fast development and stable releases.

On the other hand, I could have another tag like latest-stable pointing to the last release, would that interest you?

@Huskydog9988
Copy link
Author

The idea of the latest-stable as a tag is all I'm really looking for. If you were to implement it, I would most certainty utilize it.

@qdm12
Copy link
Owner

qdm12 commented Aug 4, 2021

Would a :v3 tag be alright instead? And it would point to the latest v3.x.x release, since I may do a v4.0.0 release one day.

I'll also try to do e. g. v3.21 tags pointing to the latest v3.21.x release.

@Huskydog9988
Copy link
Author

All of that would be good, I actually like the v3 tag idea more as that would minimize braking changes. The only concern I would have is the v3.21 tag idea. It seems like there are very few patches and much more minor changes, thus the tag wouldn't get much use.

@jathek
Copy link

jathek commented Aug 5, 2021

You seem to be doing it through custom code in your action, so you'll probably just tweak that, but the below usage of docker/metadata-action handles it pretty well for me.

  • when I push github tag vX.Y.Z, I get image tags latest, X, X.Y, and X.Y.Z
  • when I push github tag random, I get image tag random
  • when I push anything to main, I get image tag main

Below is easily tweaked to give latest whenever you push to main.

      - name: Check for semver tag
        id: semvercheck
        run: |
          if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
            MATCH=true
          else
            MATCH=false
          fi
          if [[ ! ${{ github.ref }} =~ ^refs/tags/v0\. ]]; then
            MATCH=$MATCH_nonzero
          fi
          echo ::set-output name=match::$MATCH

      # extract metadata (tags, labels) for Docker
      # https://github.com/docker/metadata-action
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          flavor: |
            latest=false
          images: |
            ${{ env.IMAGE_NAME }}
            ${{ env.GHCR }}/${{ env.IMAGE_NAME }}
          tags: |
            type=ref,event=branch
            type=ref,event=pr
            type=ref,event=tag,enable=${{ !startsWith(steps.semvercheck.outputs.match, 'true') }}
            type=semver,pattern={{version}},enable=${{ startsWith(steps.semvercheck.outputs.match, 'true') }}
            type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(steps.semvercheck.outputs.match, 'true') }}
            type=semver,pattern={{major}},enable=${{ startsWith(steps.semvercheck.outputs.match, 'true_nonzero') }}
            type=raw,value=latest,enable=${{ startsWith(steps.semvercheck.outputs.match, 'true') }}

Edited to fix some minor warnings when the semver tag pattern noticed a non-semver tag.

@qdm12
Copy link
Owner

qdm12 commented Oct 16, 2021

Thanks @nearcatch this definitely helped.

In the end I'm using:

      - name: Check for semver tag
        id: semvercheck
        run: |
          if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
            MATCH=true
          else
            MATCH=false
          fi
          if [[ ! ${{ github.ref }} =~ ^refs/tags/v0\. ]]; then
            MATCH=$MATCH_nonzero
          fi
          echo ::set-output name=match::$MATCH

      # extract metadata (tags, labels) for Docker
      # https://github.com/docker/metadata-action
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          flavor: |
            latest=${{ github.ref == 'refs/heads/master' }}
          images: |
            qmcgaw/gluetun
            qmcgaw/private-internet-access
          tags: |
            type=ref,event=branch,enable=${{ github.ref != 'refs/heads/master' }}
            type=ref,event=pr
            type=ref,event=tag,enable=${{ !startsWith(steps.semvercheck.outputs.match, 'true') }}
            type=semver,pattern=v{{major}}.{{minor}}.{{patch}},enable=${{ startsWith(steps.semvercheck.outputs.match, 'true') }}
            type=semver,pattern=v{{major}}.{{minor}},enable=${{ startsWith(steps.semvercheck.outputs.match, 'true') }}
            type=semver,pattern=v{{major}},enable=${{ startsWith(steps.semvercheck.outputs.match, 'true_nonzero') }}
            type=raw,value=latest,enable=${{ !startsWith(steps.semvercheck.outputs.match, 'true') }}

It seems to push :latest on commits pushed to master, and I'll check if it works on the next Github release. Let's wait for next release to make sure this works before closing it.

@Huskydog9988 Huskydog9988 changed the title Feature request: Make latest lag point to latest release and not a dev build Feature request: Make latest tag point to latest release and not a dev build Oct 16, 2021
@qdm12
Copy link
Owner

qdm12 commented Nov 28, 2021

@nearcatch unfortunately

type=ref,event=branch,enable=${{ github.ref != 'refs/heads/master' }}
type=ref,event=pr
type=ref,event=tag,enable=${{ !startsWith(steps.semvercheck.outputs.match, 'true') }}
type=semver,pattern=v{{major}}.{{minor}}.{{patch}},enable=${{ startsWith(steps.semvercheck.outputs.match, 'true') }}
type=semver,pattern=v{{major}}.{{minor}},enable=${{ startsWith(steps.semvercheck.outputs.match, 'true') }}
type=semver,pattern=v{{major}},enable=${{ startsWith(steps.semvercheck.outputs.match, 'true_nonzero') }}
type=raw,value=latest,enable=${{ !startsWith(steps.semvercheck.outputs.match, 'true') }}

and

tags: ${{ steps.meta.outputs.tags }}

only pushed v3.26.0 on the last release. Any idea how to fix it to push also v3 and v3.26?

Workflow relevant logs:

https://github.com/qdm12/gluetun/runs/4340897678?check_suite_focus=true#step:7:26

@jathek
Copy link

jathek commented Nov 29, 2021

only pushed v3.26.0 on the last release. Any idea how to fix it to push also v3 and v3.26?

I have no idea why but it's actually failing here, with any semver tag that isn't v0.Y.Z. This makes the semvercheck.outputs.match variable empty. Then the v<major>.<minor>.<patch> semver is being published by this line, as the raw tag:

type=ref,event=tag,enable=${{ !startsWith(steps.semvercheck.outputs.match, 'true') }}

while these lines for the v<major>, v<major>.<minor>, and v<major>.<minor>.<patch> semver tags are ignored:
type=semver,pattern=v{{major}}.{{minor}}.{{patch}},enable=${{ startsWith(steps.semvercheck.outputs.match, 'true') }}
type=semver,pattern=v{{major}}.{{minor}},enable=${{ startsWith(steps.semvercheck.outputs.match, 'true') }}
type=semver,pattern=v{{major}},enable=${{ startsWith(steps.semvercheck.outputs.match, 'true_nonzero') }}

I've done some quick testing and this code seems to work properly with non-zero semver tags:

      - name: Check for semver tag
        id: semvercheck
        run: |
          if [[ ${{ github.ref }} =~ ^refs\/tags\/v0\.[0-9]+\.[0-9]+$ ]]; then
            MATCH=true
          else
            MATCH=false
          fi
          if [[ ${{ github.ref }} =~ ^refs\/tags\/v[1-9]+\.[0-9]+\.[0-9]+$ ]]; then
            MATCH=true_nonzero
          fi
          echo ::set-output name=match::$MATCH

@qdm12
Copy link
Owner

qdm12 commented Jan 23, 2022

Thanks @nearcatch

Changes applied in 55e609c unfortunately it still didn't work for v3.27.0 😢 logs. I'll try again for v3.28.0 next time.

@qdm12
Copy link
Owner

qdm12 commented Feb 21, 2022

I'm going to write my own Github action to do all this, the current build setup is just misbehaving and hard to reason about/configure. Key points will be:

  • on pr tag as :pr-PRID
  • do not do anything on push to branches other than master/main
  • on push to master/main, tag as :latest
  • on tag
    • tag as v0.1 and v0.1.0 for semver starting with v0
    • tag as v3, v3.28 and v3.28.0 for semver nit starting with v0
    • tag as :tagname otherwise

I'll try to get this done asap for release v3.28.0.

@qdm12
Copy link
Owner

qdm12 commented Feb 26, 2022

Done in 2b09b9c! 👍 I ended up fixing the existing docker-meta action this morning.

You now have image tag :v3, :v3.28 and v3.28.0 all pointing to the same image. You might want to use image tag :v3 to only update once it's relatively stable. The :latest tag still points to the master branch.

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

No branches or pull requests

3 participants