Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flood-io/is-published-on-npm
A GitHub Action to check if the current repositories package is published on NPM.
https://github.com/flood-io/is-published-on-npm
Last synced: 2 months ago
JSON representation
A GitHub Action to check if the current repositories package is published on NPM.
- Host: GitHub
- URL: https://github.com/flood-io/is-published-on-npm
- Owner: flood-io
- License: mit
- Created: 2021-01-15T04:06:20.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T13:17:00.000Z (about 2 years ago)
- Last Synced: 2024-11-04T14:46:25.404Z (2 months ago)
- Language: TypeScript
- Size: 2.5 MB
- Stars: 8
- Watchers: 6
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flood-io/is-published-on-npm
[![Test Workflow Status](https://github.com/flood-io/is-published-on-npm/workflows/Test/badge.svg)](https://github.com/flood-io/is-published-on-npm/actions)
This GitHub Action checks if a repositories package version as defined in `package.json` is published on NPM and sets outputs accordingly.
Check the example to see how this could be helpful to automating your release workflow.
## Usage
### Pre-requisites
Your workflow job must first checkout your repository and setup node before using this action, for example:
```yml
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
```### Inputs
- `dir`: The directory containing the `package.json` to check is published. Default: `./`.
### Outputs
- `published`: `'true'` if the package with `name` and `version` as defined in `package.json` is published, `'false'` if it isn't. **Note**: This value is, as are all GitHub Action outputs, a **string**.
- `version`: The `version` as defined in `package.json`.### Example workflow - Publish a new version if not published on NPM
On every `push` to branch `master`, publish the package to NPM if it isn't already published.
```yml
name: Publish Packageon:
push:
branches:
- masterjobs:
publish:
name: Publish Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: flood-io/is-published-on-npm@v1
id: is-published
- run: npm publish
if: ${{ steps.is-published.outputs.published == 'false' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
```### Example workflow - Create a GitHub Release if not published on NPM
On every `push` to branch `master`, create a new GitHub release if it isn't already published to NPM.
```yml
name: Release Packageon:
push:
branches:
- masterjobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: flood-io/is-published-on-npm@v1
id: is-published
- name: Release
if: ${{ steps.is-published.outputs.published == 'false' }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.is-published.outputs.version }}
release_name: Release ${{ steps.is-published.outputs.version }}
draft: false
prerelease: false
```## License
The scripts and documentation in this project are released under the [MIT License](LICENSE).