Skip to content

Commit

Permalink
Add "latest" tag, but only for final releases
Browse files Browse the repository at this point in the history
using combination of a standard GHA action
and our custom code (as it doesn't support
PEP440-compatible versioning)
  • Loading branch information
gdubicki committed May 16, 2021
1 parent 3377e50 commit 924bb55
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
42 changes: 34 additions & 8 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,44 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

# we want just the version as a tag, so remove the 'refs/tags/v' prefix
- run: |
version="${github_ref/refs\/tags\/v/}"
echo "version=$version" >> $GITHUB_ENV
env:
github_ref: ${{ github.ref }}
- name: Get tags
shell: python
run: |
import re
from packaging.version import parse
version = "${{ github.ref }}".replace("refs/tags/v", "")
image = "${{ github.repository }}"
tags = set()
# full version
tags.add(f"{image}:{version}")
if not parse(version).is_prerelease:
# only final and post-releases should get the tags
# used for automatic use of latest *stable* version
# major_version
major_version = re.search(r'(\d+?)\.', version).group(1)
tags.add(f"{image}:{major_version}")
# major_version.minor_version
major_and_minor_version = re.search(r'(\d+?\.\d+?)\.', version).group(1)
tags.add(f"{image}:{major_and_minor_version}")
tags.add(f"{image}:latest")
tags = ",".join(sorted(list(tags)))
print(f"::set-output name=tags::{tags}")
id: tags

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64
push: true
tags: |
ghcr.io/voxpupuli/puppetboard:${{ env.version }}
tags: ${{ steps.tags.outputs.tags }}
2 changes: 1 addition & 1 deletion puppetboard/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Puppetboard version module
#

__version__ = '3.1.0.post2'
__version__ = '3.1.0.post3'

0 comments on commit 924bb55

Please sign in to comment.