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.

chore(quill): base publish version on npm, not the repo (#64534)

Adam Leith14c450de93ed
diff --git a/.github/workflows/publish-quill-npm.yml b/.github/workflows/publish-quill-npm.yml
index 45f18bbd4be5..53a969527f20 100644
--- a/.github/workflows/publish-quill-npm.yml
+++ b/.github/workflows/publish-quill-npm.yml
@@ -13,8 +13,12 @@ on:
- latest
permissions:
- contents: write
+ contents: read
+# Serialized on purpose, and load-bearing for collision-safety: the bump base
+# is read live from npm, so two concurrent dispatches could read the same base
+# and collide on publish. Do not narrow the group (e.g. per-tag) or flip
+# cancel-in-progress to true — that reintroduces the race this PR closes.
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
@@ -26,7 +30,7 @@ jobs:
timeout-minutes: 15
environment: Release
permissions:
- contents: write
+ contents: read
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -44,24 +48,60 @@ jobs:
- name: Ensure modern npm (OIDC trusted publishing support)
run: npm install -g [email protected]
+ # Version base is the highest version LIVE ON NPM for this package,
+ # not the in-repo package.json. master is branch-protected with no
+ # bypass actor, so the bumped version can never be committed back —
+ # the repo always lags. Basing on npm makes the workflow
+ # self-correcting: each run publishes above whatever's already on the
+ # registry, so a stale repo can't cause a "version already exists"
+ # collision. The repo package.json only seeds the very first publish
+ # of a never-published package.
+ #
+ # We base on the semver max across ALL dist-tags, not the dispatched
+ # tag's version, because (a) a per-tag lookup E404s identically for
+ # "tag absent on a published package" and "package absent", and
+ # (b) the tags are skewed here (`latest` trails `alpha`), so basing
+ # on one tag could bump backwards into an existing version. npm's
+ # `versions` array is in publish order, not semver order, so the max
+ # is computed explicitly with semver precedence.
- name: Bump versions
env:
NPM_TAG: ${{ inputs.tag }}
run: |
- git config user.name "github-actions[bot]"
- git config user.email "github-actions[bot]@users.noreply.github.com"
BUMP_TYPE=$( [ "$NPM_TAG" = "latest" ] && echo "patch" || echo "prerelease" )
+ bump() {
+ local pkg_name="$1"
+ # A genuine E404 means the package was never published, so we
+ # fall back to the repo version as the seed. Any other npm
+ # error (registry outage, auth) must fail the run rather than
+ # silently reuse a stale base and risk a republish collision.
+ local base versions_json
+ if versions_json=$(npm view "$pkg_name" versions --json 2>/tmp/npm-view-err); then
+ base=$(printf '%s' "$versions_json" | node -e 'function cmp(a,b){const pa=a.split("-"),pb=b.split("-");const ma=pa[0].split(".").map(Number),mb=pb[0].split(".").map(Number);for(let i=0;i<3;i++){if(ma[i]!==mb[i])return ma[i]-mb[i]}if(!pa[1]&&!pb[1])return 0;if(!pa[1])return 1;if(!pb[1])return -1;const ia=pa[1].split("."),ib=pb[1].split(".");for(let i=0;i<Math.max(ia.length,ib.length);i++){if(ia[i]===undefined)return -1;if(ib[i]===undefined)return 1;const na=/^\d+$/.test(ia[i]),nb=/^\d+$/.test(ib[i]);if(na&&nb){const d=Number(ia[i])-Number(ib[i]);if(d)return d}else if(na)return -1;else if(nb)return 1;else if(ia[i]!==ib[i])return ia[i]<ib[i]?-1:1}return 0}const vs=JSON.parse(require("fs").readFileSync(0,"utf8"));const a=Array.isArray(vs)?vs:[vs];console.log(a.length?a.reduce((m,v)=>cmp(v,m)>0?v:m):"")')
+ else
+ if grep -q "E404" /tmp/npm-view-err; then
+ base=""
+ else
+ echo "::error::npm view $pkg_name versions failed (not a 404):" >&2
+ cat /tmp/npm-view-err >&2
+ return 1
+ fi
+ fi
+ # --allow-same-version because the seed may already match the repo.
+ if [ -n "$base" ]; then
+ npm version "$base" --no-git-tag-version --allow-same-version >/dev/null
+ fi
+ npm version "$BUMP_TYPE" --no-git-tag-version >/dev/null
+ node -p "require('./package.json').version"
+ }
cd packages/quill/packages/tokens
- npm version "$BUMP_TYPE" --no-git-tag-version
- TOKENS_V=$(node -p "require('./package.json').version")
+ TOKENS_V=$(bump "@posthog/quill-tokens")
echo "Bumped @posthog/quill-tokens to $TOKENS_V ($BUMP_TYPE)"
cd ../quill
- npm version "$BUMP_TYPE" --no-git-tag-version
- QUILL_V=$(node -p "require('./package.json').version")
+ QUILL_V=$(bump "@posthog/quill")
echo "Bumped @posthog/quill to $QUILL_V ($BUMP_TYPE)"
cd ../charts
- npm version "$BUMP_TYPE" --no-git-tag-version
- CHARTS_V=$(node -p "require('./package.json').version")
+ CHARTS_V=$(bump "@posthog/quill-charts")
echo "Bumped @posthog/quill-charts to $CHARTS_V ($BUMP_TYPE)"
- name: Install dependencies
@@ -143,16 +183,12 @@ jobs:
run: |
echo "summary=@posthog/quill-tokens@${TOKENS_VERSION}, @posthog/quill@${QUILL_VERSION}, @posthog/quill-charts@${CHARTS_VERSION}" >> $GITHUB_OUTPUT
- - name: Commit version bump
- run: |
- git add packages/quill/packages/tokens/package.json packages/quill/packages/quill/package.json packages/quill/packages/charts/package.json
- TOKENS_V=$(node -p "require('./packages/quill/packages/tokens/package.json').version")
- QUILL_V=$(node -p "require('./packages/quill/packages/quill/package.json').version")
- CHARTS_V=$(node -p "require('./packages/quill/packages/charts/package.json').version")
- git commit -m "chore(quill): bump quill-tokens to $TOKENS_V, quill to $QUILL_V, quill-charts to $CHARTS_V [skip ci]"
- if ! git push; then
- echo "::warning::git push failed (likely branch protection). Versions were published successfully but package.json not updated in repo. A manual bump or PR may be needed."
- fi
+ # No commit-back to master: it's branch-protected with no bypass
+ # actor, and a package.json bump trips the PR-approval agent's
+ # deny-list (T2-never) and is skipped as bot-authored — so an
+ # auto-merging PR could never land unattended. The published version
+ # is sourced from npm in the "Bump versions" step instead, so the
+ # in-repo package.json is allowed to lag without causing collisions.
- name: Notify Slack
if: ${{ !cancelled() }}
diff --git a/packages/quill/packages/charts/package.json b/packages/quill/packages/charts/package.json
index 925d80d43b09..f1f74cf80315 100644
--- a/packages/quill/packages/charts/package.json
+++ b/packages/quill/packages/charts/package.json
@@ -1,6 +1,6 @@
{
"name": "@posthog/quill-charts",
- "version": "0.3.0-beta.15",
+ "version": "0.3.0-beta.16",
"description": "Canvas-based charting library for trends, dashboards, and any chart that needs to render thousands of points smoothly. D3 (scale/shape/color/array sub-packages) powers the scales; the canvas does the drawing; React handles overlays.",
"license": "MIT",
"repository": {
diff --git a/packages/quill/packages/quill/package.json b/packages/quill/packages/quill/package.json
index 7068efaabe94..0eb9cb4ae919 100644
--- a/packages/quill/packages/quill/package.json
+++ b/packages/quill/packages/quill/package.json
@@ -1,6 +1,6 @@
{
"name": "@posthog/quill",
- "version": "0.3.0-beta.15",
+ "version": "0.3.0-beta.16",
"description": "PostHog's unified design system — primitives, components, and blocks designed to be compiled by the consumer's Tailwind v4.",
"license": "MIT",
"repository": {
diff --git a/packages/quill/packages/tokens/package.json b/packages/quill/packages/tokens/package.json
index a0d08e761d91..5c66a1d6a8b6 100644
--- a/packages/quill/packages/tokens/package.json
+++ b/packages/quill/packages/tokens/package.json
@@ -1,6 +1,6 @@
{
"name": "@posthog/quill-tokens",
- "version": "0.3.0-beta.15",
+ "version": "0.3.0-beta.16",
"license": "MIT",
"repository": {
"type": "git",