feat: conversations widget #1281
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
| name: Validate Versioning | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| check-version-change-is-present-and-allowed: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for major version bumps | |
| id: check-major | |
| run: | | |
| # Get only added changeset files in this PR | |
| changesets=$(git diff --name-only --diff-filter=A origin/${{ github.base_ref }}...HEAD | grep '^\.changeset/.*\.md$' | grep -v 'README.md' || true) | |
| if [ -z "$changesets" ]; then | |
| echo "No new changesets found in this PR" | |
| echo "no_changesets=true" >> $GITHUB_OUTPUT | |
| # Check if PR has release label | |
| has_release_label=$(echo '${{ toJSON(github.event.pull_request.labels) }}' | jq -r '.[] | select(.name == "release") | .name') | |
| if [ -n "$has_release_label" ]; then | |
| echo "❌ Error: PR has 'release' label but no changeset found" | |
| exit 1 | |
| fi | |
| exit 0 | |
| fi | |
| echo "Found new changesets in this PR:" | |
| echo "$changesets" | |
| echo "no_changesets=false" >> $GITHUB_OUTPUT | |
| # Check each new changeset for major version bumps to posthog-js | |
| major_found=false | |
| major_file="" | |
| for changeset in $changesets; do | |
| echo "Checking $changeset" | |
| # Check if the file contains 'posthog-js': major | |
| if grep -q "'posthog-js':[[:space:]]*major" "$changeset"; then | |
| echo "❌ Error: Major version bump detected for 'posthog-js' in $changeset" | |
| echo "The 'posthog-js' package is autoloaded by clients and must not have breaking changes." | |
| major_found=true | |
| major_file="$changeset" | |
| break | |
| fi | |
| done | |
| if [ "$major_found" = "true" ]; then | |
| echo "major_bump_found=true" >> $GITHUB_OUTPUT | |
| echo "changeset_file=$major_file" >> $GITHUB_OUTPUT | |
| exit 1 | |
| else | |
| echo "✅ No major version bumps found for 'posthog-js' in new changesets" | |
| echo "major_bump_found=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Remove outdated comments | |
| if: always() | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const noChangesetFound = '${{ steps.check-major.outputs.no_changesets }}' === 'true'; | |
| const majorBumpFound = '${{ steps.check-major.outputs.major_bump_found }}' === 'true'; | |
| // If there ARE changesets now, remove the "no changeset" comment | |
| if (!noChangesetFound) { | |
| const noChangesetComment = comments.find(comment => | |
| comment.user.type === 'Bot' && | |
| comment.body.includes('No Changeset Found') | |
| ); | |
| if (noChangesetComment) { | |
| await github.rest.issues.deleteComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: noChangesetComment.id | |
| }); | |
| console.log('Removed outdated "No Changeset Found" comment'); | |
| } | |
| } | |
| // If there is NO major bump now, remove the "major bump" comment | |
| if (!majorBumpFound) { | |
| const majorBumpComment = comments.find(comment => | |
| comment.user.type === 'Bot' && | |
| comment.body.includes('Major Version Bump Detected for posthog-js') | |
| ); | |
| if (majorBumpComment) { | |
| await github.rest.issues.deleteComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: majorBumpComment.id | |
| }); | |
| console.log('Removed outdated "Major Version Bump" comment'); | |
| } | |
| } | |
| - name: Comment on PR | |
| if: failure() && steps.check-major.outputs.major_bump_found == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const comment = `## ⚠️ Major Version Bump Detected for posthog-js | |
| This PR contains a changeset with a **major version bump** for \`posthog-js\` in file: \`${{ steps.check-major.outputs.changeset_file }}\` | |
| ### Why is this blocked? | |
| The \`posthog-js\` package is autoloaded by clients and **must not have breaking changes**. Major version bumps would break existing client integrations. | |
| ### What should you do? | |
| - If this is a breaking change, please reconsider the implementation to maintain backwards compatibility | |
| - Change the version bump to \`minor\` or \`patch\` in the changeset file | |
| - You maybe want to change the \`defaults\` version of the config? | |
| To update the changeset, run: | |
| \`\`\`bash | |
| pnpm changeset | |
| \`\`\` | |
| And select a non-breaking version bump for \`posthog-js\`.`; | |
| // Check if we already commented | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const botComment = comments.find(comment => | |
| comment.user.type === 'Bot' && | |
| comment.body.includes('Major Version Bump Detected for posthog-js') | |
| ); | |
| if (botComment) { | |
| // Update existing comment | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body: comment | |
| }); | |
| } else { | |
| // Create new comment | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: comment | |
| }); | |
| } | |
| - name: Comment about missing changeset | |
| if: always() && steps.check-major.outputs.no_changesets == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const hasReleaseLabel = context.payload.pull_request.labels.some(label => label.name === 'release'); | |
| const comment = hasReleaseLabel | |
| ? `## ❌ No Changeset Found (Build Failed) | |
| This PR has the \`release\` label but doesn't include a changeset. A changeset is **required** when the release label is present. | |
| ### How to add a changeset | |
| Run this command and follow the prompts: | |
| \`\`\`bash | |
| pnpm changeset | |
| \`\`\` | |
| **Remember:** Never use \`major\` version bumps for \`posthog-js\` as it's autoloaded by clients.` | |
| : `## 📝 No Changeset Found | |
| This PR doesn't include a changeset. A changeset (and the release label) is required to release a new version. | |
| ### How to add a changeset | |
| Run this command and follow the prompts: | |
| \`\`\`bash | |
| pnpm changeset | |
| \`\`\` | |
| **Remember:** Never use \`major\` version bumps for \`posthog-js\` as it's autoloaded by clients.`; | |
| // Check if we already commented about missing changeset | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const botComment = comments.find(comment => | |
| comment.user.type === 'Bot' && | |
| comment.body.includes('No Changeset Found') | |
| ); | |
| if (botComment) { | |
| // Update existing comment | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body: comment | |
| }); | |
| } else { | |
| // Create new comment | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: comment | |
| }); | |
| } |