Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(ci): make hogql-parser publish robust to PyPI CDN cache lag (#60643)

Robbie4d35e50cdb23
diff --git a/.github/workflows/build-hogql-parser-rs.yml b/.github/workflows/build-hogql-parser-rs.yml
index b095b60b9391..5bf3873ef7ae 100644
--- a/.github/workflows/build-hogql-parser-rs.yml
+++ b/.github/workflows/build-hogql-parser-rs.yml
@@ -28,13 +28,15 @@ jobs:
fetch-depth: 0
filter: blob:none
- - name: Check if rust/hogql/parser/ has changed
+ - name: Check if rust/hogql/parser/ or the workflow has changed
id: changed-files
uses: step-security/changed-files@2e07db73e5ccdb319b9a6c7766bd46d39d304bad # v47.0.5
with:
files_yaml: |
parser:
- rust/hogql/parser/**
+ workflow:
+ - .github/workflows/build-hogql-parser-rs.yml
- name: Check if version was bumped
shell: bash
@@ -42,6 +44,7 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PARSER_CHANGED: ${{ steps.changed-files.outputs.parser_any_changed }}
+ WORKFLOW_CHANGED: ${{ steps.changed-files.outputs.workflow_any_changed }}
IS_FORK: ${{ github.event.pull_request.head.repo.full_name != 'PostHog/posthog' }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
@@ -50,23 +53,30 @@ jobs:
local=$(grep -m1 '^version = ' rust/hogql/parser/pyproject.toml | sed -E 's/version = "(.*)"/\1/')
echo "local-version=$local" >> $GITHUB_OUTPUT
if [[ "$PARSER_CHANGED" == 'true' ]]; then
- # PyPI returns 404 until the first publish — treat as "needs release".
- published=$(curl -fSsl https://pypi.org/pypi/hogql-parser-rs/json 2>/dev/null | jq -r '.info.version' || echo '')
- if [[ "$published" != "$local" ]]; then
- parser_release_needed='true'
- else
- message_body="It looks like the code of \`hogql-parser-rs\` changed in this PR, but its version stayed the same at $local. 👀"
- message_body+=$'\n'"Bump the version in \`rust/hogql/parser/Cargo.toml\` AND \`rust/hogql/parser/pyproject.toml\` (the two must match) before merging."
- if [[ "$IS_FORK" == 'true' ]]; then
- message_body+=$'\n'"This needs to be performed on a branch created on the PostHog/posthog repo itself. A PostHog team member can assist with this."
- fi
- existing=$(gh api "repos/${{ github.repository }}/issues/$PR_NUMBER/comments" --jq '.[] | select(.user.login == "github-actions[bot]") | select(.body | test("hogql-parser-rs.*version stayed the same.*👀")) | .id' | tail -1)
- if [[ -n "$existing" ]]; then
- gh api "repos/${{ github.repository }}/issues/comments/$existing" -X PATCH -f body="$message_body"
+ # 200 = version already on PyPI, 404 = needs release.
+ http_code=$(curl -o /dev/null -sSL -w '%{http_code}' "https://pypi.org/pypi/hogql-parser-rs/$local/json")
+ if [[ "$http_code" == '404' ]]; then
+ parser_release_needed='true'
+ elif [[ "$http_code" == '200' ]]; then
+ message_body="It looks like the code of \`hogql-parser-rs\` changed in this PR, but its version stayed the same at $local. 👀"
+ message_body+=$'\n'"Bump the version in \`rust/hogql/parser/Cargo.toml\` AND \`rust/hogql/parser/pyproject.toml\` (the two must match) before merging."
+ if [[ "$IS_FORK" == 'true' ]]; then
+ message_body+=$'\n'"This needs to be performed on a branch created on the PostHog/posthog repo itself. A PostHog team member can assist with this."
+ fi
+ existing=$(gh api "repos/${{ github.repository }}/issues/$PR_NUMBER/comments" --jq '.[] | select(.user.login == "github-actions[bot]") | select(.body | test("hogql-parser-rs.*version stayed the same.*👀")) | .id' | tail -1)
+ if [[ -n "$existing" ]]; then
+ gh api "repos/${{ github.repository }}/issues/comments/$existing" -X PATCH -f body="$message_body"
+ else
+ gh pr comment "$PR_NUMBER" --body "$message_body"
+ fi
else
- gh pr comment "$PR_NUMBER" --body "$message_body"
+ echo "::warning::Unexpected HTTP $http_code from PyPI for hogql-parser-rs $local; assuming not yet published."
+ parser_release_needed='true'
fi
- fi
+ fi
+ # Exercise the release pipeline on workflow-only edits; skip-existing makes publish a no-op.
+ if [[ "$WORKFLOW_CHANGED" == 'true' ]]; then
+ parser_release_needed='true'
fi
echo "parser-release-needed=$parser_release_needed" >> $GITHUB_OUTPUT
@@ -176,6 +186,7 @@ jobs:
with:
# Attaches the attestations generated above to the PyPI release.
attestations: true
+ skip-existing: true
- name: Get app token
id: app-token
diff --git a/.github/workflows/build-hogql-parser.yml b/.github/workflows/build-hogql-parser.yml
index 083f27d59989..399c43737db1 100644
--- a/.github/workflows/build-hogql-parser.yml
+++ b/.github/workflows/build-hogql-parser.yml
@@ -27,13 +27,15 @@ jobs:
fetch-depth: 0 # Fetching all for comparison since last push (not just last commit)
filter: blob:none
- - name: Check if common/hogql_parser/ has changed
+ - name: Check if common/hogql_parser/ or the workflow has changed
id: changed-files
uses: step-security/changed-files@2e07db73e5ccdb319b9a6c7766bd46d39d304bad # v47.0.5
with:
files_yaml: |
parser:
- common/hogql_parser/**
+ workflow:
+ - .github/workflows/build-hogql-parser.yml
- name: Check if version was bumped
shell: bash
@@ -41,16 +43,18 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PARSER_CHANGED: ${{ steps.changed-files.outputs.parser_any_changed }}
+ WORKFLOW_CHANGED: ${{ steps.changed-files.outputs.workflow_any_changed }}
IS_FORK: ${{ github.event.pull_request.head.repo.full_name != 'PostHog/posthog' }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
parser_release_needed='false'
if [[ "$PARSER_CHANGED" == 'true' ]]; then
- published=$(curl -fSsl https://pypi.org/pypi/hogql-parser/json | jq -r '.info.version')
local=$(cd common/hogql_parser && python setup.py --version)
- if [[ "$published" != "$local" ]]; then
+ # 200 = version already on PyPI, 404 = needs release.
+ http_code=$(curl -o /dev/null -sSL -w '%{http_code}' "https://pypi.org/pypi/hogql-parser/$local/json")
+ if [[ "$http_code" == '404' ]]; then
parser_release_needed='true'
- else
+ elif [[ "$http_code" == '200' ]]; then
message_body="It looks like the code of \`hogql-parser\` changed in this PR, but its version stayed the same at $local. 👀"
message_body+=$'\n'"Make sure to resolve this in \`common/hogql_parser/setup.py\` before merging!"
if [[ "$IS_FORK" == 'true' ]]; then
@@ -63,8 +67,15 @@ jobs:
else
gh pr comment "$PR_NUMBER" --body "$message_body"
fi
+ else
+ echo "::warning::Unexpected HTTP $http_code from PyPI for hogql-parser $local; assuming not yet published."
+ parser_release_needed='true'
fi
fi
+ # Exercise the release pipeline on workflow-only edits; skip-existing makes publish a no-op.
+ if [[ "$WORKFLOW_CHANGED" == 'true' ]]; then
+ parser_release_needed='true'
+ fi
echo "parser-release-needed=$parser_release_needed" >> $GITHUB_OUTPUT
build-wheels:
@@ -159,6 +170,8 @@ jobs:
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
+ with:
+ skip-existing: true
# Use GitHub app token so Actions run after commiting changes
- name: Get app token