Skip to content

Commit 077cdc9

Browse files
docs(npm): update npm doc
1 parent 9100bd5 commit 077cdc9

File tree

1 file changed

+37
-53
lines changed

1 file changed

+37
-53
lines changed

publish-npm/README.md

Lines changed: 37 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,50 @@
1-
# Publish Package NPM - Reusable Workflow Documentation
1+
# NPM Package Publish - Reusable Workflow Documentation 🚀
22

3-
## Overview
3+
## Overview 🌟
44

5-
This reusable GitHub Actions workflow automates the process of publishing an NPM package. It is configurable via inputs for the package scope, Node.js version, and registry URL. The workflow performs the following actions:
5+
This reusable GitHub Actions workflow automates the process of publishing an NPM package. It is configurable via inputs for the package scope, Node.js version, registry URL, and other options. The workflow performs the following actions:
66

7-
- Checks out your repository code.
8-
- Sets up Node.js and configures the `.npmrc` file.
9-
- Installs package dependencies using `npm ci`.
10-
- Publishes the package with provenance and public access using `npm publish`.
7+
- **Checks Out Your Repository**: Retrieves your code. 📥
8+
- **Sets Up Node.js**: Installs the specified Node.js version and configures the `.npmrc` file. ⚙️
9+
- **Installs Dependencies**: Uses `npm ci` to install the dependencies. 📦
10+
- **Publishes the Package**: Publishes the package with provenance (if enabled) and the specified access level using `npm publish`. 🎉
1111

12-
## Detailed Explanation
12+
## Workflow Inputs 🛠️
1313

14-
### Triggering the Workflow
14+
| **Input** | **Description** | **Required** | **Default** |
15+
|-------------------|-----------------------------------------------------------------------------------------------|--------------|--------------------------------------|
16+
| **scope** | Defines the NPM package scope (e.g., `@iExecBlockchainComputing`). | Yes ||
17+
| **node-version** | Specifies the Node.js version to use. | No | `20` |
18+
| **registry** | URL of the NPM registry. | No | `https://registry.npmjs.org` |
19+
| **access** | Package access level (public or restricted). | No | `public` |
20+
| **provenance** | Enable or disable npm provenance during publishing. | No | `true` |
21+
| **install-command** | Command to install dependencies. | No | `npm ci` |
22+
| **environment** | GitHub environment to use for deployment. | No | `production` |
1523

16-
- **`on: workflow_call`**
17-
This setting makes the workflow reusable, allowing it to be invoked by other workflows. Inputs can be passed during the call.
24+
### Secrets 🔐
1825

19-
### Workflow Inputs
26+
| **Secret** | **Description** | **Required** |
27+
|---------------|-------------------------------------|--------------|
28+
| **npm-token** | NPM token for authentication. | Yes |
2029

21-
- **`scope`**
22-
- **Description:** Defines the NPM package scope (e.g., `@iExecBlockchainComputing`).
23-
- **Required:** Yes.
30+
## Job and Steps ⚙️
2431

25-
- **`node-version`**
26-
- **Description:** Specifies the version of Node.js to use.
27-
- **Default:** `20`
28-
- **Required:** No.
32+
### Job Name: `build`
2933

30-
- **`registry-url`**
31-
- **Description:** URL of the NPM registry.
32-
- **Default:** `https://registry.npmjs.org`
33-
- **Required:** No.
34+
- **Runs On**: `ubuntu-latest`.
35+
- **Environment**: Uses the environment specified in `inputs.environment`.
36+
- **Permissions**:
37+
- `contents: read` – to access repository contents. 🔍
38+
- `packages: write` – to allow package publication. ✨
39+
- `id-token: write` – for authentication purposes. 🔑
3440

35-
### Job and Steps
41+
## How to Use This Reusable Workflow 🔄
3642

37-
- **Job Name (`build`):**
38-
- Runs on `ubuntu-latest`.
39-
- **Permissions:**
40-
- `contents: read` – to access repository contents.
41-
- `packages: write` – to allow package publication.
43+
1. **Save the Workflow File**
44+
Place this YAML file (e.g., `publish-npm.yml`) in the `.github/workflows/` directory of your repository. 💾
4245

43-
- **Steps:**
44-
- **Checkout Repository:**
45-
Uses `actions/checkout@v4` to retrieve your code.
46-
47-
- **Setup Node.js:**
48-
Uses `actions/setup-node@v4` to configure Node.js. This step also sets up the `.npmrc` file with the provided registry URL and scope.
49-
50-
- **Install Dependencies:**
51-
Executes `npm ci` to install dependencies from the `package-lock.json` file.
52-
53-
- **Publish Package:**
54-
Executes `npm publish --provenance --access public` to publish the package.
55-
- The `NODE_AUTH_TOKEN` environment variable is set from `${{ secrets.NPM_TOKEN }}` for authentication.
56-
57-
## How to Use This Reusable Workflow
58-
59-
1. **Save the Workflow File:**
60-
Place this YAML file (e.g., `publish-npm.yml`) in the `.github/workflows/` directory of your repository.
61-
62-
2. **Call the Reusable Workflow:**
63-
In another workflow file (for example, triggered by a release), invoke this reusable workflow as follows:
46+
2. **Call the Reusable Workflow**
47+
In another workflow file (e.g., triggered by a release), invoke this reusable workflow like so:
6448

6549
```yaml
6650
name: Call Publish Package NPM Workflow
@@ -74,10 +58,10 @@ This reusable GitHub Actions workflow automates the process of publishing an NPM
7458
with:
7559
scope: '@iExecBlockchainComputing'
7660
node-version: '20'
77-
registry-url: 'https://registry.npmjs.org'
61+
registry: 'https://registry.npmjs.org'
7862
secrets:
7963
npm-token: ${{ secrets.NPM_TOKEN }}
8064
```
8165
82-
3. **Configure Secrets:**
83-
Ensure that the `NPM_TOKEN` secret is added to your repository's settings. This token is required to authenticate with the NPM registry during publishing.
66+
3. **Configure Secrets**
67+
Ensure that the `NPM_TOKEN` secret is added to your repositorys settings. This token is required to authenticate with the NPM registry during publishing. 🔑

0 commit comments

Comments
 (0)