chore: bump version to 4.5.0 (#523) #54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A workflow for validating that release branch versions match the version in code | |
| name: Version Number Validation | |
| # Triggers the workflow when we open/update a PR from a rel/* branch | |
| on: | |
| push: | |
| branches: | |
| - 'rel/*' | |
| tags: | |
| - '*' | |
| jobs: | |
| version-check: | |
| name: Verify Version Number Matches Branch/Tag | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Extract version from branch name and strings.xml, then compare them | |
| - name: Validate Version Match | |
| id: validate_version_match | |
| run: | | |
| # Determine if this is a tag or branch push | |
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| VERSION_NAME="${GITHUB_REF#refs/tags/}" | |
| echo "Detected tag push: $VERSION_NAME" | |
| elif [[ "${GITHUB_REF}" == refs/heads/rel/* ]]; then | |
| BRANCH_NAME="${GITHUB_REF#refs/heads/}" | |
| if [[ $BRANCH_NAME =~ ^rel/(.+)$ ]]; then | |
| VERSION_NAME="${BASH_REMATCH[1]}" | |
| echo "Detected rel/* branch push: $VERSION_NAME" | |
| else | |
| ERROR_MESSAGE="Error: branch name does not match expected pattern" | |
| echo "$ERROR_MESSAGE" | |
| echo "ERROR_MESSAGE=$ERROR_MESSAGE" >> $GITHUB_ENV | |
| exit 1 | |
| fi | |
| else | |
| echo "Info: Not a rel/* branch or tag push. Exiting successfully." | |
| exit 0 | |
| fi | |
| # Extract version from strings.xml | |
| STRINGS_VERSION=$(grep -o '<string name="klaviyo_sdk_version_override">[^<]*</string>' sdk/core/src/main/res/values/strings.xml | sed 's/.*>\([^<]*\)<.*/\1/') | |
| echo "strings.xml version: $STRINGS_VERSION" | |
| # Compare versions | |
| if [ "$VERSION_NAME" = "$STRINGS_VERSION" ]; then | |
| echo "✅ Version match confirmed: $VERSION_NAME" | |
| else | |
| ERROR_MESSAGE="❌ Version mismatch! Expected version: $VERSION_NAME, strings.xml version: $STRINGS_VERSION. Use ./bump_version.sh to update the version number in this branch/tag (or correct the branch/tag name)." | |
| echo "$ERROR_MESSAGE" | |
| echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV | |
| echo "STRINGS_VERSION=$STRINGS_VERSION" >> $GITHUB_ENV | |
| echo "ERROR_MESSAGE=$ERROR_MESSAGE" >> $GITHUB_ENV | |
| exit 1 | |
| fi | |
| # Send Slack notification on failure | |
| - name: Send Slack notification on failure | |
| if: failure() | |
| uses: slackapi/slack-github-action@v2.1.1 | |
| with: | |
| webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| webhook-type: incoming-webhook | |
| payload: | | |
| text: "🚨 Release Version Mismatch Detected" | |
| blocks: | |
| - type: "section" | |
| text: | |
| type: "mrkdwn" | |
| text: "🚨 Release Version Mismatch Detected\n" | |
| - type: "section" | |
| text: | |
| type: "mrkdwn" | |
| text: "*Repository:* ${{ github.repository }}\n*Ref:* `${{ github.ref_name }}`\n*Expected Version:* `${{ env.VERSION_NAME }}`\n*strings.xml Version:* `${{ env.STRINGS_VERSION }}`\n*Error:* `${{ env.ERROR_MESSAGE }}`\n*Action:* Please run `./bump_version.sh` to update the version number in this branch/tag (or correct the branch/tag name)." | |
| - type: "section" | |
| text: | |
| type: "mrkdwn" | |
| text: "*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>" |