Skip to content

Commit a869aa3

Browse files
authored
Merge pull request #2 from e7d/feat/main/github-actions
Publish major (`image:x`) and minor (`image:x.y`) tags of the Docker images
2 parents 2f3a123 + 90f0563 commit a869aa3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

.github/workflows/docker-image.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,19 @@ jobs:
3434
cache-to: type=registry,ref=${{ vars.DOCKERHUB_IMAGE }}:buildcache,mode=max
3535
push: true
3636
tags: ${{ vars.DOCKERHUB_IMAGE }}:${{ github.sha }}
37-
- name: Push "tag"
37+
- name: Push semver tags
3838
if: github.ref_type == 'tag'
3939
run: |
4040
GITHUB_REF=${{ github.ref }}
41-
TAG=${GITHUB_REF#refs/tags/}
42-
docker buildx imagetools create \
43-
--tag ${{ vars.DOCKERHUB_IMAGE }}:${TAG} \
44-
${{ vars.DOCKERHUB_IMAGE }}:${{ github.sha }}
45-
- name: Push "latest"
41+
GITHUB_TAG=${GITHUB_REF#refs/tags/}
42+
TAGS=""
43+
if [ "${GITHUB_TAG}" != *-* ]; then # if not a pre-release
44+
TAGS+=" --tag ${{ vars.DOCKERHUB_IMAGE }}:${GITHUB_TAG%%.*}" # major version tag (e.g. 1)
45+
TAGS+=" --tag ${{ vars.DOCKERHUB_IMAGE }}:${GITHUB_TAG%.*}" # major.minor version tag (e.g. 1.2)
46+
fi
47+
TAGS+=" --tag ${{ vars.DOCKERHUB_IMAGE }}:${GITHUB_TAG}" # full version tag (e.g. 1.2.3-rc.4)
48+
docker buildx imagetools create ${TAGS} ${{ vars.DOCKERHUB_IMAGE }}:${{ github.sha }}
49+
- name: Push "latest" tag
4650
if: github.ref == 'refs/heads/main'
4751
run: |
4852
docker buildx imagetools create \

0 commit comments

Comments
 (0)