-
🧠 Smart
Only publishes if the version number inpackage.json
differs from the latest on NPM -
🛠 Configurable
Customize the version-checking behavior, the registry URL, and path of your package -
🔐 Secure
Keeps your NPM access token secret. Doesn't write it to~/.npmrc
-
⚡ Fast
100% JavaScript (which is faster than Docker) and bundled to optimize loading time -
📤 Outputs
Exposes the old and new version numbers, and the type of change (major, minor, patch, etc.) as variables that you can use in your workflow.
By default, the only thing you need to do is set the token
parameter to your NPM auth token.
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 10
- run: npm install
- run: npm test
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
You can set any or all of the following input parameters:
Name | Type | Required? | Default | Description |
---|---|---|---|---|
token |
string | yes | The NPM auth token to use for publishing | |
registry |
string | no | https://registry.npmjs.org/ | The NPM registry URL to use |
package |
string | no | ./package.json | The path of your package.json file |
check-version |
boolean | no | true | Only publish to NPM if the version number in package.json differs from the latest on NPM |
npm-publish exposes some output variables, which you can use in later steps of your workflow. To access the output variables, you'll need to set an id
for the npm-publish step.
steps:
- id: publish
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
- if: steps.publish.type != 'none'
run: |
echo "Version changed: ${{ steps.publish.old-version }} => ${{ steps.publish.version }}"
Variable | Type | Description |
---|---|---|
type |
string | The type of version change that occurred ("major", "minor", "patch", etc.). If there was no version change, then type will be "none". |
version |
string | The version that was published |
old-version |
string | The version number that was previously published to NPM |
Contributions, enhancements, and bug-fixes are welcome! File an issue on GitHub and submit a pull request.
To build the project locally on your computer:
-
Clone this repo
git clone https://github.com/JS-DevTools/npm-publish.git
-
Install dependencies
npm install
-
Build the code
npm run build
-
Run the tests
npm test
npm-publish is 100% free and open-source, under the MIT license. Use it however you want.
Thanks to these awesome companies for their support of Open Source developers ❤