@@ -80,65 +80,16 @@ jobs:
8080 echo "Running smoke test against $TEST_IMAGE"
8181 docker run --rm "$TEST_IMAGE" node -v
8282
83- - id : image_reference_builder
84- name : Generate image references
85- env :
86- NEW_TAG : ${{ steps.tag_builder.outputs.build_tag }}
87- run : |
88- NEW_MAJOR=$(echo "${{ env.NEW_TAG }}" | cut -d. -f1)
89- REPO="$GITHUB_REPOSITORY"
90-
91- LATEST_TAG_NAME=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${REPO}/releases/latest" | python -c 'import sys,json;print(json.load(sys.stdin).get("tag_name","") or "")')
92- LATEST_CLEAN="${LATEST_TAG_NAME#v}"
93- if [ -z "$LATEST_CLEAN" ]; then
94- LATEST_MAJOR=-1
95- else
96- LATEST_MAJOR=$(echo "$LATEST_CLEAN" | cut -d. -f1)
97- fi
98-
99- echo "Latest tag: $LATEST_CLEAN"
100-
101- REF1="${{ vars.DOCKERHUB_USERNAME }}/${{ env.REPO }}:${{ env.NEW_TAG }}"
102- REF2="ghcr.io/${{ github.repository_owner }}/${{ env.REPO }}:${{ env.NEW_TAG }}"
103-
104- NEW_CLEAN="${{ env.NEW_TAG }}"
105-
106- if [ -z "$LATEST_CLEAN" ]; then
107- IS_GREATER=1
108- else
109- # strip leading 'v' from both
110- N="${NEW_CLEAN#v}"
111- L="${LATEST_CLEAN#v}"
112- MAX=$(printf '%s\n%s\n' "$L" "$N" | sort -V | tail -n1)
113- if [ "$MAX" = "$N" ] && [ "$N" != "$L" ]; then
114- IS_GREATER=1
115- else
116- IS_GREATER=0
117- fi
118- fi
119-
120- if [ "$IS_GREATER" -eq 1 ]; then
121- echo "New version is greater than latest; tagging as latest"
122- REF3="${{ vars.DOCKERHUB_USERNAME }}/${{ env.REPO }}:latest"
123- REF4="ghcr.io/${{ github.repository_owner }}/${{ env.REPO }}:latest"
124- REFS="$(printf '%s\n%s\n%s\n%s' "$REF1" "$REF2" "$REF3" "$REF4")"
125- else
126- echo "Not tagging as latest (new <= latest)"
127- REFS="$(printf '%s\n%s' "$REF1" "$REF2")"
128- fi
129-
130- echo "Generating image references:\n$REFS"
131-
132- echo "image_references<<EOF" >> $GITHUB_OUTPUT
133- printf "%s\n" "$REFS" >> $GITHUB_OUTPUT
134- echo "EOF" >> $GITHUB_OUTPUT
135-
13683 - name : Build & Push image to registries
13784 uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # 6.18.0
13885 with :
13986 context : source/typescript-node
14087 platforms : linux/amd64,linux/arm64
14188 push : true
142- tags : ${{ steps.image_reference_builder.outputs.image_references }}
89+ tags : |
90+ ${{ vars.DOCKERHUB_USERNAME }}/${{ env.REPO }}:${NEW_TAG}
91+ ${{ vars.DOCKERHUB_USERNAME }}/${{ env.REPO }}:latest
92+ ghcr.io/${{ github.repository_owner }}/${{ env.REPO }}:${NEW_TAG}
93+ ghcr.io/${{ github.repository_owner }}/${{ env.REPO }}:latest
14394 cache-from : type=gha
14495 cache-to : type=gha,mode=max
0 commit comments