diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a73fcd..047f615 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -19,20 +19,24 @@ jobs: name: delete_unrelated_tags command: | ALL_TAGS=$(git tag --points-at HEAD) + if [ -z "$ALL_TAGS" ]; then echo "No-op as there are no tags on the current commit ($(git rev-parse HEAD))" exit 0 fi + if [ -z "${CIRCLE_TAG:+x}" ]; then echo "Non-tag build, deleting all tags which point to HEAD: [${ALL_TAGS/$'\n'/,}]" echo "$ALL_TAGS" | while read -r TAG; do git tag -d "$TAG" 1>/dev/null; done exit 0 fi + TAGS_TO_DELETE=$(echo "$ALL_TAGS" | grep -v "^$CIRCLE_TAG$" || :) if [ -z "$TAGS_TO_DELETE" ]; then echo "No-op as exactly one tag ($CIRCLE_TAG) points to HEAD" exit 0 fi + echo "Detected tag build, deleting all tags except '$CIRCLE_TAG' which point to HEAD: [${TAGS_TO_DELETE/$'\n'/,}]" echo "$TAGS_TO_DELETE" | while read -r TAG; do git tag -d "$TAG" 1>/dev/null; done - restore_cache: { key: 'gradle-wrapper-v1-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' } @@ -67,20 +71,24 @@ jobs: name: delete_unrelated_tags command: | ALL_TAGS=$(git tag --points-at HEAD) + if [ -z "$ALL_TAGS" ]; then echo "No-op as there are no tags on the current commit ($(git rev-parse HEAD))" exit 0 fi + if [ -z "${CIRCLE_TAG:+x}" ]; then echo "Non-tag build, deleting all tags which point to HEAD: [${ALL_TAGS/$'\n'/,}]" echo "$ALL_TAGS" | while read -r TAG; do git tag -d "$TAG" 1>/dev/null; done exit 0 fi + TAGS_TO_DELETE=$(echo "$ALL_TAGS" | grep -v "^$CIRCLE_TAG$" || :) if [ -z "$TAGS_TO_DELETE" ]; then echo "No-op as exactly one tag ($CIRCLE_TAG) points to HEAD" exit 0 fi + echo "Detected tag build, deleting all tags except '$CIRCLE_TAG' which point to HEAD: [${TAGS_TO_DELETE/$'\n'/,}]" echo "$TAGS_TO_DELETE" | while read -r TAG; do git tag -d "$TAG" 1>/dev/null; done - restore_cache: { key: 'gradle-wrapper-v1-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}' }