NPM Publish
name: NPM Publish
repoFullName: Default Repository
on:
push:
branches:
- Default Branch
jobs:
run-publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: $\{env.workDir}
strategy:
matrix:
node-version:
- 18.16.0
steps:
- uses: actions/checkout@v3
name: Checkout code
- uses: actions/setup-node@v3
name: Set up Node.js
with:
node-version: $\{ matrix.node-version }
- name: Install dependencies
run: npm install
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: $\{ secrets.NPM_AUTH_TOKEN }
Explanation:
name: NPM Publish
This line sets the name of the Onetab workflow. In this case, it’s named “NPM Publish”.
repoFullName: Default Repository
This line specifies the full name of the repository where the workflow will be applied. It’s set to “Default Repository”.
on:
push:
branches:
- master
This section defines when the workflow should be triggered. In this case, it triggers the workflow when there is a push event to the “master” branch.
jobs:
run-publish:
Defines a job named “run-publish”. A job is a set of steps that execute on the same runner.
runs-on: ubuntu-latest
Specifies that the job will run on a virtual machine with the latest version of Ubuntu.
defaults:
run:
working-directory:
Defines defaults for the run section of steps. In this case, no specific working directory is specified.
strategy:
matrix:
node-version:
- 18.16.0
Defines a strategy for the job, creating a matrix of configurations. In this case, it specifies a matrix with a single configuration for the node version, set to “18.16.0”.
steps:
- uses: actions/checkout@v3
name: Checkout code
Checks out the repository at the specified version (v3).
- uses: actions/setup-node@v3
name: Set up Node.js
Sets up the Node.js environment using the setup-node action (v3). The version of Node.js is determined by the matrix configuration.
- name: Install dependencies
run: npm install
Installs project dependencies using npm.
- name: Publish to npm
run: npm publish
Publishes the package to the npm registry. The NODE_AUTH_TOKEN environment variable is used for authentication.