GitHub Action to wait for an npm package version to become available
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/.
Notify users only when a release was published. The repository dispatch event type is set to [current repositories full name] release
(e.g. gr2m/release-notifire action
)
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
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.