From b9f8addaea7ca276666916e967ed58c3a068371f Mon Sep 17 00:00:00 2001 From: nrslib <38722970+nrslib@users.noreply.github.com> Date: Tue, 10 Feb 2026 10:08:35 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20stable=20release=E6=99=82=E3=81=ABnext?= =?UTF-8?q?=20dist-tag=E3=82=92=E8=87=AA=E5=8B=95=E5=90=8C=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/auto-tag.yml | 37 +++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml index bab7fad..502d777 100644 --- a/.github/workflows/auto-tag.yml +++ b/.github/workflows/auto-tag.yml @@ -52,12 +52,47 @@ jobs: run: | VERSION="${{ needs.tag.outputs.tag }}" VERSION="${VERSION#v}" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" if echo "$VERSION" | grep -qE '(alpha|beta|rc|next)'; then echo "tag=next" >> "$GITHUB_OUTPUT" else echo "tag=latest" >> "$GITHUB_OUTPUT" fi - - run: npm publish --tag ${{ steps.npm-tag.outputs.tag }} + - name: Publish package + run: npm publish --tag ${{ steps.npm-tag.outputs.tag }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Sync next tag on stable release + if: steps.npm-tag.outputs.tag == 'latest' + run: | + PACKAGE_NAME=$(node -p "require('./package.json').name") + VERSION="${{ steps.npm-tag.outputs.version }}" + + for attempt in 1 2 3; do + if npm dist-tag add "${PACKAGE_NAME}@${VERSION}" next; then + exit 0 + fi + if [ "$attempt" -eq 3 ]; then + echo "Failed to sync next tag after 3 attempts." + exit 1 + fi + sleep $((attempt * 5)) + done + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Verify dist-tags + run: | + PACKAGE_NAME=$(node -p "require('./package.json').name") + LATEST=$(npm view "${PACKAGE_NAME}" dist-tags.latest) + NEXT=$(npm view "${PACKAGE_NAME}" dist-tags.next || true) + + echo "latest=${LATEST}" + echo "next=${NEXT}" + + if [ "${{ steps.npm-tag.outputs.tag }}" = "latest" ] && [ "${LATEST}" != "${NEXT}" ]; then + echo "Expected next to match latest on stable release, but they differ." + exit 1 + fi