From 2fbb8576bc0e18f89c8922b5724aff1e1ae3a7a5 Mon Sep 17 00:00:00 2001 From: Ganesh Murthy Date: Fri, 12 Jul 2024 15:53:03 -0400 Subject: [PATCH] Fixes #1564: Ignore deleted tags when calculating BUILD_NUMBERS (#1565) * Fixes #1564: Ignore deleted tags when calculating BUILD_NUMBERS * Code review comments: Fixed BUILD_NUMBER when creating draft release (cherry picked from commit f5586287d577b3f2ec935c27be1fc5f51aacdc2a) --- .github/workflows/image-manual.yml | 6 +++--- .github/workflows/release-candidate.yml | 6 +++--- .github/workflows/release-respin.yml | 6 +++--- .github/workflows/release.yml | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/image-manual.yml b/.github/workflows/image-manual.yml index 642e65fa3..f88ad1514 100644 --- a/.github/workflows/image-manual.yml +++ b/.github/workflows/image-manual.yml @@ -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; } @@ -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; } @@ -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 diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 5daa85ed5..311648376 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -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 '^\[\]$' || \ @@ -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 '^\[\]$' || \ @@ -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 diff --git a/.github/workflows/release-respin.yml b/.github/workflows/release-respin.yml index 0a4fe52f4..19ee38b35 100644 --- a/.github/workflows/release-respin.yml +++ b/.github/workflows/release-respin.yml @@ -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 @@ -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 }}" @@ -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 }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a2a3089e6..3d2dba654 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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}" | \ @@ -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 @@ -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 @@ -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