Skip to content

Commit

Permalink
Fixes #1564: Ignore deleted tags when calculating BUILD_NUMBERS (#1565)
Browse files Browse the repository at this point in the history
* Fixes #1564: Ignore deleted tags when calculating BUILD_NUMBERS

* Code review comments: Fixed BUILD_NUMBER when creating draft release

(cherry picked from commit f558628)
  • Loading branch information
ganeshmurthy committed Jul 12, 2024
1 parent 0b4b998 commit 2fbb857
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/image-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
# The version of skupper-router should be the same as the version of the image.
export VERSION="${CONTAINER_TAG}"
if [ "${CONTAINER_TAG}" != "main" ]; then
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq .tags[].name | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq '.tags[] | select(has("end_ts") | not) | .name' | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
# Only accepts tag if build_number is higher than one
# Verify if build number is unique, otherwise fail
[[ ${BUILD_NUMBER} -eq 1 ]] && { echo "The provided tag (${VERSION}) does not refer to a released image. You must provide a tag that has already been released."; exit 1; }
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
# The version of skupper-router should be the same as the version of the image.
export VERSION="${CONTAINER_TAG}"
if [ "${CONTAINER_TAG}" != "main" ]; then
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq .tags[].name | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq '.tags[] | select(has("end_ts") | not) | .name' | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
# Only accepts tag if build_number is higher than one
# Verify if build number is unique, otherwise fail
[[ ${BUILD_NUMBER} -eq 1 ]] && { echo "The provided tag (${VERSION}) does not refer to a released image. You must provide a tag that has already been released."; exit 1; }
Expand Down Expand Up @@ -157,7 +157,7 @@ jobs:
run: |
export VERSION="${CONTAINER_TAG}"
if [ "${CONTAINER_TAG}" != "main" ]; then
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq .tags[].name | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq '.tags[] | select(has("end_ts") | not) | .name' | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
echo "BUILD_NUMER(create-manifest)=${BUILD_NUMBER}"
# Only accepts tag if build_number is higher than one
# Verify if build number is unique, otherwise fail
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: |
export PROJECT_TAG="${{ env.CONTAINER_TAG }}"
export VERSION="${{ env.CONTAINER_TAG }}"
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq .tags[].name | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq '.tags[] | select(has("end_ts") | not) | .name' | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
# Verify if build number is unique, otherwise fail
curl -s "https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=eq:${VERSION}-${BUILD_NUMBER}" | \
jq .tags | grep -E '^\[\]$' || \
Expand All @@ -62,7 +62,7 @@ jobs:
echo "CONTAINER_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Build and publish skupper-router image
run: |
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq .tags[].name | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq '.tags[] | select(has("end_ts") | not) | .name' | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
# Verify if build number is unique, otherwise fail
curl -s "https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=eq:${VERSION}-${BUILD_NUMBER}" | \
jq .tags | grep -E '^\[\]$' || \
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
echo "CONTAINER_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Pull skupper-router amd64 and arm64 images and create/push manifest
run: |
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq .tags[].name | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq '.tags[] | select(has("end_ts") | not) | .name' | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export PROJECT_TAG="${{ env.CONTAINER_TAG }}"
unset PUSH_LATEST
./.github/scripts/manifest.sh
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-respin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: |
export PROJECT_TAG="${{ env.CONTAINER_TAG }}"
export VERSION="${{ env.CONTAINER_TAG }}"
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq .tags[].name | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq '.tags[] | select(has("end_ts") | not) | .name' | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
# Only accepts tag if build_number is higher than one
[[ ${BUILD_NUMBER} -eq 1 ]] && { echo "The provided tag (${VERSION}) does not refer to a released image. You must provide a tag that has already been released."; exit 1; }
# Verify if build number is unique, otherwise fail
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
- name: Build and publish skupper-router arm64 image
run: |
export VERSION="${{ env.CONTAINER_TAG }}"
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq .tags[].name | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq '.tags[] | select(has("end_ts") | not) | .name' | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
# Only accepts tag if build_number is higher than one
[[ ${BUILD_NUMBER} -eq 1 ]] && { echo "The provided tag (${VERSION}) does not refer to a released image. You must provide a tag that has already been released."; exit 1; }
export PROJECT_TAG="${{ env.CONTAINER_TAG }}"
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
- name: Pull skupper-router amd64 and arm64 images and create/push manifest
run: |
export VERSION="${{ env.CONTAINER_TAG }}"
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq .tags[].name | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq '.tags[] | select(has("end_ts") | not) | .name' | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
# Only accepts tag if build_number is higher than one
[[ ${BUILD_NUMBER} -eq 1 ]] && { echo "The provided tag (${VERSION}) does not refer to a released image. You must provide a tag that has already been released."; exit 1; }
export PROJECT_TAG="${{ env.CONTAINER_TAG }}"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: |
export PROJECT_TAG="${{ env.CONTAINER_TAG }}"
export VERSION="${{ env.CONTAINER_TAG }}"
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq .tags[].name | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq '.tags[] | select(has("end_ts") | not) | .name' | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
echo "BUILD_NUMBER=${BUILD_NUMBER}" >> $GITHUB_ENV
# Verify if build number is unique, otherwise fail
curl -s "https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=eq:${VERSION}-${BUILD_NUMBER}" | \
Expand All @@ -64,9 +64,9 @@ jobs:
echo "CONTAINER_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Build and publish skupper-router arm64 image
run: |
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq .tags[].name | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export PROJECT_TAG="${{ env.CONTAINER_TAG }}"
export VERSION="${{ env.CONTAINER_TAG }}"
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq '.tags[] | select(has("end_ts") | not) | .name' | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export PROJECT_TAG="${{ env.CONTAINER_TAG }}"
# This is a release build which means we need to push the :latest tag to the container repo.
export PUSH_LATEST=true
export PLATFORM=arm64
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
- name: Pull skupper-router amd64 and arm64 images and create/push manifest
run: |
export VERSION="${CONTAINER_TAG}"
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq .tags[].name | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq '.tags[] | select(has("end_ts") | not) | .name' | grep -E "\"${VERSION}-[0-9]+\"" | wc -l || echo 0` + 1))
export PROJECT_TAG="${{ env.CONTAINER_TAG }}"
# This is a release candidate build which means we WON'T push the :latest tag to the container repo.
export PUSH_LATEST=true
Expand All @@ -129,7 +129,7 @@ jobs:
- name: Get the build number
run: |
export VERSION="${CONTAINER_TAG}"
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq .tags[].name | grep -E "\"${VERSION}-[0-9]+\"" | wc -l`))
export BUILD_NUMBER=$((`curl -s https://quay.io/api/v1/repository/skupper/skupper-router/tag/?filter_tag_name=like:${VERSION} | jq '.tags[] | select(has("end_ts") | not) | .name' | grep -E "\"${VERSION}-[0-9]+\"" | wc -l`))
echo "BUILD_NUMER(create-release)=${BUILD_NUMBER}"
echo "BUILD_NUMBER=${BUILD_NUMBER}" >> $GITHUB_ENV
# Now that we have successfully pushed a tagged version of the skupper-router container
Expand Down

0 comments on commit 2fbb857

Please sign in to comment.