diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 29e6e81..9b95690 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -25,8 +25,8 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Validate set versions - run: ./validate_versions.sh ${{ github.event.inputs.name }} + - name: Validate the release tag + run: ./validate_release_tag.sh ${{ github.event.inputs.name }} - name: Validate pipeline status run: ./validate_pipeline_status.sh ${{ github.ref_name }} diff --git a/.version b/.version deleted file mode 100644 index 8ee7f57..0000000 --- a/.version +++ /dev/null @@ -1 +0,0 @@ -MODULE_VERSION=1.0.0 diff --git a/scripts/release/validate_release_tag.sh b/scripts/release/validate_release_tag.sh new file mode 100755 index 0000000..e505335 --- /dev/null +++ b/scripts/release/validate_release_tag.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -o nounset +set -o errexit +set -E +set -o pipefail + +CURRENT_RELEASE_TAG=$1 + +semver_pattern="^([0-9]|[1-9][0-9]*)[.]([0-9]|[1-9][0-9]*)[.]([0-9]|[1-9][0-9]*)(-[a-z][a-z0-9]*)?$" + +if ! [[ $CURRENT_RELEASE_TAG =~ $semver_pattern ]]; then + echo "Given tag \"$CURRENT_RELEASE_TAG\" does not match the expected semantic version pattern: \"$semver_pattern\"." + exit 1 +fi + diff --git a/scripts/release/validate_versions.sh b/scripts/release/validate_versions.sh deleted file mode 100755 index 867a83b..0000000 --- a/scripts/release/validate_versions.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -set -ue -source ./../../.version - -DESIRED_VERSION=$1 -if [[ "$DESIRED_VERSION" != "$MODULE_VERSION" ]]; then - echo "Versions don't match! Expected ${MODULE_VERSION} but got $DESIRED_VERSION." - echo "Please update .version file or change desired version!" - exit 1 -fi -echo "Versions match." - -IMAGE_TO_CHECK="${2:-europe-docker.pkg.dev/kyma-project/prod/template-operator}" -BUMPED_IMAGE_TAG=$(grep "${IMAGE_TO_CHECK}" ../../sec-scanners-config.yaml | cut -d : -f 2) -if [[ "$BUMPED_IMAGE_TAG" != "$DESIRED_VERSION" ]]; then - echo "Version tag in sec-scanners-config.yaml file is incorrect!" - echo "Could not find $DESIRED_VERSION." - exit 1 -fi -echo "Image version tag in sec-scanners-config.yaml does match with release tag." -exit 0