@@ -2,7 +2,7 @@ name: Release and Docker Push
22
33on :
44 push :
5- branches : [v4 ]
5+ branches : ['v3', 'v4' ]
66 paths :
77 - package.json
88 workflow_dispatch :
6666 uses : softprops/action-gh-release@v2
6767 with :
6868 tag_name : v${{ steps.version.outputs.current }}
69+ target_commitish : ${{ github.sha }}
6970 name : v${{ steps.version.outputs.current }}
7071 generate_release_notes : true
7172
@@ -105,6 +106,27 @@ jobs:
105106 echo "LOG: Docker image already exists for version ${{ steps.version.outputs.current }}. Nothing to do."
106107 exit 0
107108
109+ - name : Compute image tags
110+ if : steps.imgcheck.outputs.exists != 'true'
111+ id : tags
112+ run : |
113+ set -euo pipefail
114+ IMAGE="${{ env.REGISTRY }}/${{ steps.image.outputs.name }}"
115+ VER="${{ steps.version.outputs.current }}"
116+ MAJOR="${VER%%.*}"
117+
118+ # Always tag the exact version and the moving major tag (e.g. :3.1.7 and :3)
119+ TAGS="$IMAGE:$VER"$'\n'"$IMAGE:$MAJOR"
120+
121+ # Only the current line (v4) moves :latest
122+ if [ "${{ github.ref_name }}" = "v4" ]; then
123+ TAGS="$TAGS"$'\n'"$IMAGE:latest"
124+ fi
125+
126+ { echo "list<<EOF"; echo "$TAGS"; echo "EOF"; } >> "$GITHUB_OUTPUT"
127+ echo "LOG: Tags:"
128+ echo "$TAGS"
129+
108130 - name : Set up QEMU
109131 if : steps.imgcheck.outputs.exists != 'true'
110132 uses : docker/setup-qemu-action@v3
@@ -120,8 +142,6 @@ jobs:
120142 context : .
121143 push : true
122144 platforms : linux/amd64,linux/arm64
123- tags : |
124- ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:${{ steps.version.outputs.current }}
125- ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:latest
126- cache-from : type=gha
127- cache-to : type=gha,mode=max
145+ tags : ${{ steps.tags.outputs.list }}
146+ cache-from : type=gha,scope=${{ github.ref_name }}
147+ cache-to : type=gha,scope=${{ github.ref_name }},mode=max
0 commit comments