Search code examples
npmversioningpackage.jsongithub-actionsgit-tag

Github Action different between release created and published


since Github Releases are actually a Git Tags, I want to auto-upgrade my package.json version when there is a new Release (and tag), with Github Action.

I know I need to trigger a job on: release, but according to Github Actions docs I don't know if I need to trigger when created, published, both or all?

Github says:

Note: The release event is not triggered for draft releases.

And I created two pipelines: one on: release, type: created and one on: release, type: published.

Then I created a draft release, and then I published it.

Only the published pipeline triggered, and it was when I published the release.


Solution

  • My experience has been the opposite of what was described here on the forum. When tested:

    • If the release is created from "Draft a new release" button on the /releases page, both events will trigger, as the release goes from state "draft" to "published".
    • If the release is created by scripts like release-it, bypassing "draft" stage and becoming "published" directly, only release:published will trigger

    So apparently a release can be published without being created. Weird indeed. I'd go with published.