From 94c0addcd4541fcb45c7532063f5f9154af6c047 Mon Sep 17 00:00:00 2001 From: Dmytro Smirnov Date: Wed, 5 Aug 2026 20:36:16 +0300 Subject: [PATCH 1/2] fix: separate npm tag from release branch --- .github/workflows/npm-release-ops.yml | 19 +++++++++++++++++-- docs/workflows/npm-release-ops.md | 9 +++++++-- examples/npm-release-ops.yml | 1 + 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/npm-release-ops.yml b/.github/workflows/npm-release-ops.yml index 220b312..a816b21 100644 --- a/.github/workflows/npm-release-ops.yml +++ b/.github/workflows/npm-release-ops.yml @@ -18,6 +18,11 @@ on: required: false default: "latest" type: string + npm_tag: + description: "NPM: Dist-tag assigned to the published version (default: latest)" + required: false + default: "latest" + type: string enable_gh_release: description: "GitHub: Whether to create a GitHub release (default: true)" required: false @@ -43,6 +48,7 @@ jobs: node_version: ${{ steps.store_inputs.outputs.node_version }} provenance: ${{ steps.store_inputs.outputs.provenance }} release_branch: ${{ steps.store_inputs.outputs.release_branch }} + npm_tag: ${{ steps.store_inputs.outputs.npm_tag }} enable_gh_release: ${{ steps.store_inputs.outputs.enable_gh_release }} working_directory: ${{ steps.store_inputs.outputs.working_directory }} dist_dir: ${{ steps.store_inputs.outputs.dist_dir }} @@ -64,6 +70,7 @@ jobs: NODE_VERSION: ${{ inputs.node_version }} PROVENANCE: ${{ inputs.provenance }} RELEASE_BRANCH: ${{ inputs.release_branch }} + NPM_TAG: ${{ inputs.npm_tag }} ENABLE_GH_RELEASE: ${{ inputs.enable_gh_release }} DIST_DIR: ${{ inputs.dist_dir }} run: | @@ -72,6 +79,7 @@ jobs: echo "Node version: $NODE_VERSION" echo "Provenance: $PROVENANCE" echo "Release branch: $RELEASE_BRANCH" + echo "NPM tag: $NPM_TAG" echo "GitHub release: $ENABLE_GH_RELEASE" echo "Dist directory: $DIST_DIR" @@ -79,6 +87,7 @@ jobs: echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT echo "provenance=$PROVENANCE" >> $GITHUB_OUTPUT echo "release_branch=$RELEASE_BRANCH" >> $GITHUB_OUTPUT + echo "npm_tag=$NPM_TAG" >> $GITHUB_OUTPUT echo "enable_gh_release=$ENABLE_GH_RELEASE" >> $GITHUB_OUTPUT echo "dist_dir=$DIST_DIR" >> $GITHUB_OUTPUT @@ -86,6 +95,7 @@ jobs: echo "Node version: $NODE_VERSION" echo "Provenance: $PROVENANCE" echo "Release branch: $RELEASE_BRANCH" + echo "NPM tag: $NPM_TAG" echo "GitHub release: $ENABLE_GH_RELEASE" echo "Dist directory: $DIST_DIR" @@ -93,6 +103,7 @@ jobs: echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT echo "provenance=$PROVENANCE" >> $GITHUB_OUTPUT echo "release_branch=$RELEASE_BRANCH" >> $GITHUB_OUTPUT + echo "npm_tag=$NPM_TAG" >> $GITHUB_OUTPUT echo "enable_gh_release=$ENABLE_GH_RELEASE" >> $GITHUB_OUTPUT echo "working_directory=$WORKING_DIRECTORY" >> $GITHUB_OUTPUT echo "dist_dir=$DIST_DIR" >> $GITHUB_OUTPUT @@ -169,6 +180,7 @@ jobs: NODE_VERSION: ${{ steps.store_inputs.outputs.node_version }} PROVENANCE: ${{ steps.store_inputs.outputs.provenance }} RELEASE_BRANCH: ${{ steps.store_inputs.outputs.release_branch }} + NPM_TAG: ${{ steps.store_inputs.outputs.npm_tag }} ENABLE_GH_RELEASE: ${{ steps.store_inputs.outputs.enable_gh_release }} WORKING_DIRECTORY: ${{ steps.store_inputs.outputs.working_directory }} DIST_DIR: ${{ steps.store_inputs.outputs.dist_dir }} @@ -184,6 +196,7 @@ jobs: echo "Node: $NODE_VERSION" echo "Provenance: $PROVENANCE" echo "Release branch: $RELEASE_BRANCH" + echo "NPM tag: $NPM_TAG" echo "GitHub release: $ENABLE_GH_RELEASE" echo "Working dir: $WORKING_DIRECTORY" echo "Dist dir: $DIST_DIR" @@ -308,7 +321,7 @@ jobs: name: ${{ needs.config.outputs.current_branch }} env: IS_RELEASE_BRANCH: ${{ needs.config.outputs.is_release_branch }} - RELEASE_BRANCH: ${{ needs.config.outputs.release_branch }} + NPM_TAG: ${{ needs.config.outputs.npm_tag }} RELEASE_VERSION: ${{ needs.config.outputs.release_version }} NODE_VERSION: ${{ needs.config.outputs.node_version }} PACKAGE_NAME: ${{ needs.config.outputs.package_name }} @@ -340,7 +353,7 @@ jobs: if: env.IS_RELEASE_BRANCH == 'true' env: PROVENANCE: ${{ env.PROVENANCE }} - NPM_TAG: ${{ env.RELEASE_BRANCH }} + NPM_TAG: ${{ env.NPM_TAG }} run: | echo "🚢 Publishing to NPM..." PUBLISH_ARGS=() @@ -361,6 +374,7 @@ jobs: env: CURRENT_BRANCH: ${{ needs.config.outputs.current_branch }} RELEASE_BRANCH: ${{ needs.config.outputs.release_branch }} + NPM_TAG: ${{ needs.config.outputs.npm_tag }} IS_RELEASE_BRANCH: ${{ needs.config.outputs.is_release_branch }} ENABLE_GH_RELEASE: ${{ needs.config.outputs.enable_gh_release }} NPM_RELEASE_RESULT: ${{ needs.npm-release.result }} @@ -372,6 +386,7 @@ jobs: echo "-------------------" echo "Branch: $CURRENT_BRANCH" echo "Release branch: $RELEASE_BRANCH" + echo "NPM tag: $NPM_TAG" echo "Is release branch: $IS_RELEASE_BRANCH" echo "NPM release result: $NPM_RELEASE_RESULT" echo "GitHub release result: $GITHUB_RELEASE_RESULT" diff --git a/docs/workflows/npm-release-ops.md b/docs/workflows/npm-release-ops.md index 9274fa8..7505680 100644 --- a/docs/workflows/npm-release-ops.md +++ b/docs/workflows/npm-release-ops.md @@ -25,7 +25,7 @@ Call this workflow from your release pipeline (see [example](../../examples/npm- - Runs tests (`npm test --if-present`). - Runs build (`npm run build --if-present`). -- Runs publish step with provenance (if enabled). +- Runs publish step with provenance (if enabled) and the configured npm dist-tag. - Creates a GitHub release if `enable_gh_release` is true. ### Non-Release Branch @@ -41,6 +41,7 @@ Call this workflow from your release pipeline (see [example](../../examples/npm- | `node_version` | Node.js: Version to use | `24` | | `provenance` | NPM: Enable provenance | `true` | | `release_branch` | Branch: Deployment branch that triggers releases | `latest` | +| `npm_tag` | NPM: Dist-tag assigned to the published version | `latest` | | `enable_gh_release` | GitHub: Whether to create a GitHub release | `true` | | `dist_dir` | Common: Directory containing package.json | `dist` | @@ -68,6 +69,7 @@ Called workflows cannot elevate permissions beyond caller scope. - Use `dist_dir` to point at the directory containing `package.json`. - The release version is read from `package.json`. +- `release_branch` controls which Git branch may publish; `npm_tag` controls the npm dist-tag independently. - Use Trusted Publishing (`id-token: write`) for `npm publish`. - Static npm publish tokens are a legacy approach and are not supported or maintained in this workflow. @@ -80,7 +82,8 @@ jobs: uses: udx/reusable-workflows/.github/workflows/npm-release-ops.yml@master with: node_version: "24" - release_branch: "latest" + release_branch: "main" + npm_tag: "latest" dist_dir: "dist" provenance: true enable_gh_release: true @@ -88,6 +91,8 @@ jobs: gh_token: ${{ secrets.GH_TOKEN }} ``` +Set `npm_tag` to a non-default tag only when that is intentional (for example, `next`). Existing callers that relied on `release_branch` also setting the npm tag should set `npm_tag` explicitly. + ### If your own reusable workflow declares `npm_token` and `package_version` The following pattern is valid for that separate workflow contract: diff --git a/examples/npm-release-ops.yml b/examples/npm-release-ops.yml index db63a95..c498a12 100644 --- a/examples/npm-release-ops.yml +++ b/examples/npm-release-ops.yml @@ -14,6 +14,7 @@ jobs: with: node_version: "24" release_branch: "latest" + npm_tag: "latest" provenance: "true" dist_dir: "dist" enable_gh_release: "true" From af82a415836d224cbdb6e3bb36e4eb663a421cda Mon Sep 17 00:00:00 2001 From: Dmytro Smirnov Date: Wed, 5 Aug 2026 21:11:18 +0300 Subject: [PATCH 2/2] fix: write npm release inputs once --- .github/workflows/npm-release-ops.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.github/workflows/npm-release-ops.yml b/.github/workflows/npm-release-ops.yml index a816b21..f000ade 100644 --- a/.github/workflows/npm-release-ops.yml +++ b/.github/workflows/npm-release-ops.yml @@ -74,23 +74,6 @@ jobs: ENABLE_GH_RELEASE: ${{ inputs.enable_gh_release }} DIST_DIR: ${{ inputs.dist_dir }} run: | - - echo "Inputs Preview:" - echo "Node version: $NODE_VERSION" - echo "Provenance: $PROVENANCE" - echo "Release branch: $RELEASE_BRANCH" - echo "NPM tag: $NPM_TAG" - echo "GitHub release: $ENABLE_GH_RELEASE" - echo "Dist directory: $DIST_DIR" - - echo "Set output from inputs..." - echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT - echo "provenance=$PROVENANCE" >> $GITHUB_OUTPUT - echo "release_branch=$RELEASE_BRANCH" >> $GITHUB_OUTPUT - echo "npm_tag=$NPM_TAG" >> $GITHUB_OUTPUT - echo "enable_gh_release=$ENABLE_GH_RELEASE" >> $GITHUB_OUTPUT - echo "dist_dir=$DIST_DIR" >> $GITHUB_OUTPUT - echo "Inputs Preview:" echo "Node version: $NODE_VERSION" echo "Provenance: $PROVENANCE"