From 9292734a23b8f2be97ae378ce338e3589d85a167 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 2 Jul 2026 15:18:30 +0200 Subject: [PATCH] ci: standardize SDK release failure telemetry --- .github/workflows/release.yml | 67 ++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index feedd73..bbdd254 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -67,7 +67,7 @@ jobs: steps: - name: Notify Slack - Approved if: needs.notify-approval-needed.outputs.slack_ts != '' - uses: posthog/.github/.github/actions/slack-thread-reply@5fc4680761e8ac29a61b212756230eba0e276d8c + uses: posthog/.github/.github/actions/slack-thread-reply@cb0979b67dcd585828b61ac45927eef4da8f6287 # main with: slack_bot_token: ${{ secrets.SLACK_CLIENT_LIBRARIES_BOT_TOKEN }} slack_channel_id: ${{ vars.SLACK_APPROVALS_CLIENT_LIBRARIES_CHANNEL_ID }} @@ -158,9 +158,53 @@ jobs: echo "commit-hash=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" fi + - name: Resolve release failure metadata + id: release-failure-metadata + if: ${{ failure() }} + run: | + set -euo pipefail + package_name="" + package_version="" + separator="" + for package_json in posthog-ruby/package.json posthog-rails/package.json; do + if [ -f "$package_json" ]; then + package_name_part=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("name", ""))' "$package_json") + version=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("version", ""))' "$package_json") + if [ -n "$package_name_part" ] && [ -n "$version" ]; then + package_name="${package_name}${separator}${package_name_part}" + package_version="${package_version}${separator}${package_name_part}@v${version}" + separator=", " + fi + fi + done + echo "package_name=$package_name" >> "$GITHUB_OUTPUT" + echo "package_version=$package_version" >> "$GITHUB_OUTPUT" + + - name: Send failure event to PostHog + if: ${{ failure() }} + continue-on-error: true + uses: PostHog/posthog-github-action@9a6a19d360820ab4d95ecc4a5a7564062c895f84 # v1.3.0 + with: + posthog-token: "${{ secrets.POSTHOG_PROJECT_API_KEY }}" + event: "posthog-sdk-github-release-workflow-failure" + properties: >- + { + "commitSha": "${{ github.sha }}", + "jobStatus": "${{ job.status }}", + "ref": "${{ github.ref }}", + "repository": "${{ github.repository }}", + "sdk": "posthog-ruby", + "jobName": "version-bump", + "packageName": "${{ steps.release-failure-metadata.outputs.package_name || 'unknown' }}", + "packageVersion": "${{ steps.release-failure-metadata.outputs.package_version || 'unknown' }}", + "actionUrl": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}", + "alertText": ":rotating_light: Failed to prepare release for posthog-ruby :rotating_light:", + "alertContext": "The version bump/changelog step failed before packages were published." + } + - name: Notify Slack - Failed if: ${{ failure() && needs.notify-approval-needed.outputs.slack_ts != '' }} - uses: posthog/.github/.github/actions/slack-thread-reply@5fc4680761e8ac29a61b212756230eba0e276d8c + uses: posthog/.github/.github/actions/slack-thread-reply@cb0979b67dcd585828b61ac45927eef4da8f6287 # main with: slack_bot_token: ${{ secrets.SLACK_CLIENT_LIBRARIES_BOT_TOKEN }} slack_channel_id: ${{ vars.SLACK_APPROVALS_CLIENT_LIBRARIES_CHANNEL_ID }} @@ -199,7 +243,7 @@ jobs: - name: Notify Slack - Rejected if: steps.check-rejection.outputs.was_rejected == 'true' - uses: posthog/.github/.github/actions/slack-thread-reply@5fc4680761e8ac29a61b212756230eba0e276d8c + uses: posthog/.github/.github/actions/slack-thread-reply@cb0979b67dcd585828b61ac45927eef4da8f6287 # main with: slack_bot_token: ${{ secrets.SLACK_CLIENT_LIBRARIES_BOT_TOKEN }} slack_channel_id: ${{ vars.SLACK_APPROVALS_CLIENT_LIBRARIES_CHANNEL_ID }} @@ -332,22 +376,29 @@ jobs: - name: Send failure event to PostHog if: ${{ failure() }} - uses: PostHog/posthog-github-action@58dea254b598fb5d469c0699c98af8288a7f7650 # v1.2.0 + continue-on-error: true + uses: PostHog/posthog-github-action@9a6a19d360820ab4d95ecc4a5a7564062c895f84 # v1.3.0 with: posthog-token: "${{ secrets.POSTHOG_PROJECT_API_KEY }}" - event: "posthog-ruby-github-release-workflow-failure" + event: "posthog-sdk-github-release-workflow-failure" properties: >- { "commitSha": "${{ github.sha }}", "jobStatus": "${{ job.status }}", "ref": "${{ github.ref }}", + "repository": "${{ github.repository }}", + "sdk": "posthog-ruby", + "jobName": "publish", "packageName": "${{ matrix.package.name }}", - "packageVersion": "${{ steps.detect-version.outputs.version }}" + "packageVersion": "${{ steps.detect-version.outputs.version || 'unknown' }}", + "actionUrl": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}", + "alertText": ":rotating_light: Failed to release ${{ matrix.package.name }}@${{ steps.detect-version.outputs.version }} :rotating_light:", + "alertContext": "The package publish step failed." } - name: Notify Slack - Failed if: ${{ failure() && needs.notify-approval-needed.outputs.slack_ts != '' }} - uses: posthog/.github/.github/actions/slack-thread-reply@5fc4680761e8ac29a61b212756230eba0e276d8c + uses: posthog/.github/.github/actions/slack-thread-reply@cb0979b67dcd585828b61ac45927eef4da8f6287 # main with: slack_bot_token: ${{ secrets.SLACK_CLIENT_LIBRARIES_BOT_TOKEN }} slack_channel_id: ${{ vars.SLACK_APPROVALS_CLIENT_LIBRARIES_CHANNEL_ID }} @@ -362,7 +413,7 @@ jobs: if: always() && needs.publish.result == 'success' && needs.notify-approval-needed.outputs.slack_ts != '' steps: - name: Notify Slack - Released - uses: posthog/.github/.github/actions/slack-thread-reply@5fc4680761e8ac29a61b212756230eba0e276d8c + uses: posthog/.github/.github/actions/slack-thread-reply@cb0979b67dcd585828b61ac45927eef4da8f6287 # main with: slack_bot_token: ${{ secrets.SLACK_CLIENT_LIBRARIES_BOT_TOKEN }} slack_channel_id: ${{ vars.SLACK_APPROVALS_CLIENT_LIBRARIES_CHANNEL_ID }}