From 5c6a5c5d07477107bbc76ed33ab4792f622a9598 Mon Sep 17 00:00:00 2001 From: AJ Lauer Barinov <102617203+andrewjl-mux@users.noreply.github.com> Date: Tue, 1 Aug 2023 15:32:28 -0700 Subject: [PATCH] ci: add pod spec version check on release branch pushes (#88) --- .github/workflows/validate-release.yml | 17 +++++++++++++++++ scripts/version-check.sh | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .github/workflows/validate-release.yml create mode 100755 scripts/version-check.sh diff --git a/.github/workflows/validate-release.yml b/.github/workflows/validate-release.yml new file mode 100644 index 00000000..95a91b70 --- /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 + diff --git a/scripts/version-check.sh b/scripts/version-check.sh new file mode 100755 index 00000000..b7beab7b --- /dev/null +++ b/scripts/version-check.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +readonly COCOAPOD_SPEC=Mux-Upload-SDK.podspec + +# Extracts the pod spec version in the form of a MAJOR.MINOR.PATCH string +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}" + +# Checks branch name for a v followed by a semantic version MAJOR.MINOR.PATCH string +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 ${COCOAPOD_SPEC} to ${release_version}" + exit 1 +fi