You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
6
6
7
-
- Checks out your repository code.
8
-
- Sets up Node.jsand 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`. 🎉
|**npm-token**| NPM token for authentication. | Yes |
20
29
21
-
-**`scope`**
22
-
-**Description:** Defines the NPM package scope (e.g., `@iExecBlockchainComputing`).
23
-
-**Required:** Yes.
30
+
## Job and Steps ⚙️
24
31
25
-
-**`node-version`**
26
-
-**Description:** Specifies the version of Node.js to use.
27
-
-**Default:**`20`
28
-
-**Required:** No.
32
+
### Job Name: `build`
29
33
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. 🔑
34
40
35
-
### Job and Steps
41
+
##How to Use This Reusable Workflow 🔄
36
42
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. 💾
42
45
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:
64
48
65
49
```yaml
66
50
name: Call Publish Package NPM Workflow
@@ -74,10 +58,10 @@ This reusable GitHub Actions workflow automates the process of publishing an NPM
74
58
with:
75
59
scope: '@iExecBlockchainComputing'
76
60
node-version: '20'
77
-
registry-url: 'https://registry.npmjs.org'
61
+
registry: 'https://registry.npmjs.org'
78
62
secrets:
79
63
npm-token: ${{ secrets.NPM_TOKEN }}
80
64
```
81
65
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 repository’s settings. This token is required to authenticate with the NPM registry during publishing. 🔑
0 commit comments