Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions .github/workflows/npm-release-ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -64,35 +70,23 @@ 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: |

echo "Inputs Preview:"
echo "Node version: $NODE_VERSION"
echo "Provenance: $PROVENANCE"
echo "Release branch: $RELEASE_BRANCH"
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 "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"
echo "Release branch: $RELEASE_BRANCH"
echo "NPM tag: $NPM_TAG"
Comment thread
fqjony marked this conversation as resolved.
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 "working_directory=$WORKING_DIRECTORY" >> $GITHUB_OUTPUT
echo "dist_dir=$DIST_DIR" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -169,6 +163,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 }}
Expand All @@ -184,6 +179,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"
Expand Down Expand Up @@ -308,7 +304,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 }}
Expand Down Expand Up @@ -340,7 +336,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=()
Expand All @@ -361,6 +357,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 }}
Expand All @@ -372,6 +369,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"
Expand Down
9 changes: 7 additions & 2 deletions docs/workflows/npm-release-ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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` |

Expand Down Expand Up @@ -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.

Expand All @@ -80,14 +82,17 @@ 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
secrets:
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:
Expand Down
1 change: 1 addition & 0 deletions examples/npm-release-ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
with:
node_version: "24"
release_branch: "latest"
npm_tag: "latest"
provenance: "true"
dist_dir: "dist"
enable_gh_release: "true"
Expand Down