diff --git a/.github/workflows/validate-release.yml b/.github/workflows/validate-release.yml new file mode 100644 index 00000000..76c65e25 --- /dev/null +++ b/.github/workflows/validate-release.yml @@ -0,0 +1,17 @@ +name: Validate release + +on: + push: + branches: + - 'releases/**' + +jobs: + versioncheck: + runs-on: macos-latest + name: Validate Versions + steps: + - name: Compare Podspec Version + uses: actions/checkout@v2 + - name: Run Version Check Script + run: ./scripts/version-check.sh + \ No newline at end of file diff --git a/scripts/version-check.sh b/scripts/version-check.sh new file mode 100755 index 00000000..6b96ab7c --- /dev/null +++ b/scripts/version-check.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +readonly COCOAPOD_SPEC=Mux-Upload-SDK.podspec + +cocoapod_spec_version=$(grep -Eo '\b[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+)?(\+[0-9A-Za-z-]+)?\b' $COCOAPOD_SPEC | awk 'NR==1') + +echo "Detected Cocoapod Spec Version: ${cocoapod_spec_version}" + +release_version=$(git branch --show-current | sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+).*/\1/') + +echo "Inferred Release Version: ${release_version}" + +if [ "${cocoapod_spec_version}" == "${release_version}" ]; then + echo "Versions match" +else + echo "Versions do not match, please update the cocoapod spec to ${release_version}" + exit 1 +fi + + +