https://github.com/gr2m/await-npm-package-version-action
GitHub Action to wait for an npm package version to become available
https://github.com/gr2m/await-npm-package-version-action
Last synced: 11 months ago
JSON representation
GitHub Action to wait for an npm package version to become available
- Host: GitHub
- URL: https://github.com/gr2m/await-npm-package-version-action
- Owner: gr2m
- License: isc
- Created: 2020-12-04T06:42:21.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-04-21T16:19:52.000Z (about 1 year ago)
- Last Synced: 2025-04-22T14:06:40.714Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 3.11 MB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# await-npm-package-version-action
> GitHub Action to wait for an npm package version to become available
[](https://github.com/gr2m/await-npm-package-version-action/actions)
When a new version is published to the npm registry using `npm publish`, it may not be immediately accessible in the npm registry. When installing the latest version of the same package right after the publish, it's likely that the previously published version will be returned. This action helps to halt the current workflow until the new version is accessible on https://registry.npmjs.org/.
## Usage
Notify users only when a release was published. The [repository dispatch event type](https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#create-a-repository-dispatch-event) is set to `[current repositories full name] release` (e.g. `gr2m/release-notifire action`)
```yml
name: Release Notification
on:
release:
types:
- published
jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: gr2m/await-npm-package-version-action@v1
- with:
package: example
version: ${{ github.event.release.tag_name }} # v1.2.3 is automatically parsed as "1.2.3"
timeout: 300 # time in seconds, defaults to 5 minutes
registry: https://npm.pkg.github.com # defaults to https://registry.npmjs.org
# it is now save to assume that `npm install example@latest` will return the new version
```
## How it works
The action continuously sends a request to `https://registry.npmjs.org/[package]` (or another `registry` if specified as parameter) and checks if the JSON response's `versions` object has a key for the configured version.
If the looked for version is not available after 300 seconds (configurable with `timeout`), the action ends with an error.
## License
[ISC](LICENSE)