From ffafe23a80e06c105ec6b6f79348dedcf65d89b1 Mon Sep 17 00:00:00 2001 From: Akhilesh Arora Date: Sat, 9 May 2026 13:21:42 +0200 Subject: [PATCH] fix(release): resolve npm dist-tag from prerelease label Previously release.yml ran 'npm publish --access public --provenance' with no --tag flag, so every publish (including prereleases like 0.2.0-alpha.2) defaulted to 'latest'. That overrode the alpha dist-tag and meant 'npm install @datacline/langos-sdk-node' would pull a pre-release. Now we resolve the dist-tag from the version: 0.2.0-alpha.2 -> alpha 0.2.0-beta.1 -> beta 0.2.0-rc.0 -> rc 1.0.0 -> latest Prereleases stay on their own channel; default install only pulls a prerelease if the user explicitly asks (npm install @scope/pkg@alpha). --- .github/workflows/release.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ad8039..1c01eaa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,8 +68,23 @@ jobs: console.log('Tarball OK. Files:', files); " + - name: Determine npm dist-tag from version + id: dist_tag + run: | + VERSION=$(node -e "console.log(require('./package.json').version)") + # Detect prerelease (anything with a hyphen: 1.0.0-alpha.1, 1.0.0-beta.2, ...) + if [[ "$VERSION" == *-* ]]; then + # Use the prerelease label as the dist-tag (alpha/beta/rc/next) + TAG=$(echo "$VERSION" | sed -E 's/.*-([a-zA-Z]+)\..*/\1/') + [ -z "$TAG" ] && TAG=next + else + TAG=latest + fi + echo "Resolved dist-tag: $TAG (from version $VERSION)" + echo "tag=$TAG" >> "$GITHUB_OUTPUT" + - name: Publish to npm - run: npm publish --access public --provenance + run: npm publish --access public --provenance --tag "${{ steps.dist_tag.outputs.tag }}" env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}