Skip to content

Commit d4383d3

Browse files
feat(publish-npm): add dry-run option
1 parent 29174e7 commit d4383d3

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

.github/workflows/publish-npm.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ on:
7979
description: 'Version to publish (leave empty to use package.json version)'
8080
default: ''
8181
type: string
82+
dry-run:
83+
description: 'Run in dry-run mode (the package will not be published)'
84+
default: false
85+
type: boolean
8286
secrets:
8387
npm-token:
8488
description: 'NPM auth token'
@@ -144,13 +148,19 @@ jobs:
144148
env:
145149
NODE_AUTH_TOKEN: ${{ secrets.npm-token }}
146150
run: |
147-
TAG_OPT=""
151+
TAG_OPT=""
148152
if [ -n "${{ inputs.tag }}" ]; then
149153
TAG_OPT="--tag ${{ inputs.tag }}"
150154
fi
151155
156+
DRY_RUN_OPT=""
157+
if [ "${{ inputs.dry-run }}" = "true" ]; then
158+
DRY_RUN_OPT="--dry-run"
159+
fi
160+
161+
PROVENANCE_OPT=""
152162
if [ "${{ inputs.provenance }}" = "true" ]; then
153-
npm publish --access ${{ inputs.access }} $TAG_OPT --provenance
163+
PROVENANCE_OPT="--provenance"
154164
else
155-
npm publish --access ${{ inputs.access }} $TAG_OPT
156-
fi
165+
166+
npm publish --access ${{ inputs.access }} $TAG_OPT $DRY_RUN_OPT $PROVENANCE_OPT

publish-npm/README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ for the package scope, Node.js version, registry URL, and other options. The wor
2020
## Workflow Inputs 🛠️
2121

2222
| **Input** | **Description** | **Required** | **Default** |
23-
|--------------------------|---------------------------------------------------------------|--------------|-------------------------------------|
23+
| ------------------------ | ------------------------------------------------------------- | ------------ | ----------------------------------- |
2424
| **scope** | NPM package scope (e.g., `@iexec`). | No | `@iexec` |
2525
| **node-version** | Node.js version to use. | No | `20` |
2626
| **registry** | NPM registry URL. | No | `https://registry.npmjs.org` |
@@ -40,11 +40,12 @@ for the package scope, Node.js version, registry URL, and other options. The wor
4040
| **artifact-name** | Name of an artifact to download before the build. | No | `''` (empty string) |
4141
| **artifact-path** | Destination path for the downloaded artifact. | No | `''` (empty string) |
4242
| **version** | Version to publish (leave empty to use package.json version). | No | `''` (empty string) |
43+
| **dry-run** | Run in dry-run mode (the package will not be published). | No | `false` |
4344

4445
### Secrets 🔐
4546

4647
| **Secret** | **Description** | **Required** |
47-
|---------------|-----------------|--------------|
48+
| ------------- | --------------- | ------------ |
4849
| **npm-token** | NPM auth token. | Yes |
4950

5051
## Job and Steps ⚙️
@@ -54,9 +55,9 @@ for the package scope, Node.js version, registry URL, and other options. The wor
5455
- **Runs On**: `ubuntu-latest`.
5556
- **Environment**: Uses the environment specified in `inputs.environment`.
5657
- **Permissions**:
57-
- `contents: read` – to access repository contents. 🔍
58-
- `packages: write` – to allow package publication. ✨
59-
- `id-token: write` – for authentication purposes. 🔑
58+
- `contents: read` – to access repository contents. 🔍
59+
- `packages: write` – to allow package publication. ✨
60+
- `id-token: write` – for authentication purposes. 🔑
6061

6162
## How to Use This Reusable Workflow 🔄
6263

@@ -76,14 +77,14 @@ for the package scope, Node.js version, registry URL, and other options. The wor
7677
publish:
7778
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/publish-npm.yml@main
7879
with:
79-
node-version: '22'
80-
build-command: 'npm run build:prod'
80+
node-version: "22"
81+
build-command: "npm run build:prod"
8182
run-tests: true
82-
test-command: 'npm run test:ci'
83-
lint-command: 'npm run lint'
84-
type-check-command: 'npm run check-types'
85-
format-check-command: 'npm run check-format'
86-
tag-prefix: 'v'
83+
test-command: "npm run test:ci"
84+
lint-command: "npm run lint"
85+
type-check-command: "npm run check-types"
86+
format-check-command: "npm run check-format"
87+
tag-prefix: "v"
8788
# Optional: Download an artifact before building
8889
# artifact-name: 'my-build-artifact'
8990
# artifact-path: './dist'

0 commit comments

Comments
 (0)