From 3a672561f48506952e7420735f108a40bfa7d8b9 Mon Sep 17 00:00:00 2001 From: Vigneshwer Vaidyanathan Date: Mon, 24 Aug 2026 14:45:54 -0400 Subject: [PATCH] Derive npm dist-tag from package major in publish workflow publish.yml ran a bare `npm publish`, which always moves the 'latest' dist-tag to whatever version is being published. That is wrong for maintenance releases on an older major: publishing 1.5.1 would have pointed 'latest' at it and pulled every `npm install @fragment-dev/node-client` back to the v1 line. Compare the package major against the current 'latest' major and publish older majors under a 'v' tag instead. --- .github/workflows/publish.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1e2cf46..45c7526 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -38,6 +38,20 @@ jobs: max_attempts: 2 command: yarn - - run: npm publish --access public + - name: Determine npm dist-tag + id: dist-tag + run: | + VERSION="$(npm pkg get version | tr -d '\"')" + MAJOR="${VERSION%%.*}" + LATEST_MAJOR="$(npm view @fragment-dev/node-client version 2>/dev/null | cut -d. -f1)" + if [ -n "$LATEST_MAJOR" ] && [ "$MAJOR" -lt "$LATEST_MAJOR" ]; then + TAG="v$MAJOR" + else + TAG="latest" + fi + echo "Publishing $VERSION under dist-tag $TAG" + echo "tag=$TAG" >> $GITHUB_OUTPUT + + - run: npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}