Skip to content

Automatically publish package to NPM on release. #23487

Closed
@ghost

Description

Code of Conduct

What article on docs.github.com is affected?

https://github.com/github/docs/blob/main/content/actions/publishing-packages/publishing-nodejs-packages.md

What part(s) of the article would you like to see updated?

Summary

The event trigger in the following example does not perform the function described in the docs. I experimented after looking for various event triggers and was able to do what was suggested by using 'published' instead of 'created'.

Current example

# ...
on:
  release:
    types: [created]
# ...

Suggested changes

## ...
on:
  release:
    types: ['published']
## ...

Other changes

If this change is applied I also suggest to update the following:

## Publishing packages to the npm registry

Each time you create a new release, you can trigger a workflow to publish your package. The workflow in the example below runs when the `release` event triggers with type `created`. The workflow publishes the package to the npm registry if CI tests pass.

To:

## Publishing packages to the npm registry

You can trigger a workflow to publish your NPM package every time you [publish a new release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release). The process in the following example is executed when the release event of type 'published' is triggered. If the CI tests pass, the process uploads the package to the npm registry.

Additional information

You can see a working example in this project. Before this commit I used the exact same example as suggest in the docs, but after creating the releases the workflow was not triggered. The NPM package was only published after I change the event trigger as mentioned previously.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    actionsThis issue or pull request should be reviewed by the docs actions teamcontentThis issue or pull request belongs to the Docs Content teamhelp wantedAnyone is welcome to open a pull request to fix this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions