Why is the "v" prefix ignored for alpha or beta releases?
#517
-
|
I'm hoping to get some insight into why my tags don't get processed as intended. My workflow is run on Git tag pushes where my tags follow semantic versioning (e.g. - name: Extract Docker Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=raw,value=alpha,enable=${{ github.ref_type == 'tag' && contains(github.ref, 'alpha') }}
type=raw,value=beta,enable=${{ github.ref_type == 'tag' && contains(github.ref, 'beta') }}
type=raw,value=latest,enable=${{ github.ref_type == 'tag' && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') }}
type=ref,event=branchI expect my workflow to output these Docker tags for these GitHub tags: However, these are the actual outputs I'm getting: The problem is in the Any thoughts? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
For the pre-release semver tags they are intentionally not supported for major/major.minor patterns: https://github.com/docker/metadata-action#typesemver
|
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the reply @polarathene! This has been my solution since making the post: - name: Set version variables
run: |
echo "IS_STABLE=${{ github.ref_type == 'tag' && !contains(github.ref, '-alpha.') && !contains(github.ref, '-beta.') }}" >> $GITHUB_ENV
echo "IS_ALPHA=${{ github.ref_type == 'tag' && contains(github.ref, '-alpha.') }}" >> $GITHUB_ENV
echo "IS_BETA=${{ github.ref_type == 'tag' && contains(github.ref, '-beta.') }}" >> $GITHUB_ENV
echo "IS_PRERELEASE=${{ github.ref_type == 'tag' && (contains(github.ref, '-alpha.') || contains(github.ref, '-beta.')) }}" >> $GITHUB_ENV
- name: Extract Docker Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
# X.Y.Z, X.Y, X
type=semver,pattern={{version}},enable=${{ env.IS_STABLE }}
type=semver,pattern={{major}}.{{minor}},enable=${{ env.IS_STABLE }}
type=semver,pattern={{major}},enable=${{ env.IS_STABLE }}
# vX.Y.Z, vX.Y, vX
type=semver,pattern=v{{version}},enable=${{ env.IS_STABLE }}
type=semver,pattern=v{{major}}.{{minor}},enable=${{ env.IS_STABLE }}
type=semver,pattern=v{{major}},enable=${{ env.IS_STABLE }}
# X.Y.Z-alpha.W, X.Y.Z-beta.W
type=semver,pattern={{version}},enable=${{ env.IS_PRERELEASE }}
# vX.Y.Z-alpha.W, vX.Y.Z-beta.W
type=semver,pattern={{raw}},enable=${{ env.IS_PRERELEASE }}
# alpha, beta
type=raw,value=alpha,enable=${{ env.IS_ALPHA }}
type=raw,value=beta,enable=${{ env.IS_BETA }}
# main, develop, experimental
type=ref,event=branch
# latest
type=raw,value=latest,enable=${{ env.IS_STABLE }}Definitely not perfect, it just passes the raw value when using a pre-release semvar pattern |
Beta Was this translation helpful? Give feedback.
semverwill match on the tag pattern, and it strips away thevprefix which the docs kind of mention (unless you prepend thevto the pattern as you did).For the pre-release semver tags they are intentionally not supported for major/major.minor patterns: https://github.com/docker/metadata-action#typesemver