File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
taskcluster/docker/skopeo Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,31 @@ umoci insert --image ${NAME}:final version.json /version.json
3838
3939echo " === Pushing to docker hub ==="
4040DOCKER_TAG=" ${NAME} -v${VERSION} "
41+
42+ # Get all remote tags | jq filter only starting with ${NAME}-v | Sort by version | Get the last one
43+ LATEST_REMOTE_VERSION=$( skopeo list-tags docker://$DOCKER_REPO | jq " .Tags[] | select(. | test(\" ^${NAME} -v\\\\ d\" ))" -r | sort -V | tail -1)
44+
4145skopeo copy oci:${NAME} :final docker://$DOCKER_REPO :$DOCKER_TAG
4246skopeo inspect docker://$DOCKER_REPO :$DOCKER_TAG
4347
48+ # This bit is intentionally verbose so it's easier to track when we override the latest tag
49+ if [ " ${LATEST_REMOTE_VERSION} " = " " ]; then
50+ echo " Couldn't find a remote version. Tagging as latest."
51+ skopeo copy oci:${NAME} :final docker://$DOCKER_REPO :$NAME -latest
52+ elif [ " ${LATEST_REMOTE_VERSION} " = " ${DOCKER_TAG} " ]; then
53+ echo " Updating latest tag, the latest version on remote matches the provided version."
54+ skopeo copy oci:${NAME} :final docker://$DOCKER_REPO :$NAME -latest
55+ else
56+ # Printf the latest remote version and the current tag | Sort by version | Get the last one
57+ LATEST_VERSION=$( printf " $REMOTE_VERSION \n$DOCKER_TAG " | sort -V | tail -1)
58+ # If current tag > latest remote, then we should tag as latest
59+ if [ " ${LATEST_VERSION} " != " ${REMOTE_VERSION} " ]; then
60+ echo " Updating latest tag, the current version is higher than the remote."
61+ skopeo copy oci:${NAME} :final docker://$DOCKER_REPO :$NAME -latest
62+ else
63+ echo " Skipped tagging as current tag is not higher than the remote's latest."
64+ fi
65+ fi
66+
4467echo " === Clean up ==="
4568rm -rf $HOME /.docker
You can’t perform that action at this time.
0 commit comments