Skip to content

Add GitHub hook to publish to NPM when a new release is created #226

@iaincollins

Description

@iaincollins

Currently I publish new releases manually with npm publish.

After the release of 2.0 I would like to automated this with a GitHub workflow:

.github/workflows/npm-publish.yml

# Publishes module to registry when a new release is created.
#
# The following secrets need to be configured for this workflow:
#
# * NPM_TOKEN - Auth token from npmjs.com

name: Publish to NPM

on:
  release:
    types: [created]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
      - run: npm ci
      - run: npm test

  publish-npm:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
          registry-url: https://registry.npmjs.org/
      - run: npm ci
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

One consideration that may block this is that we don't currently have a suite of tests, which I think it is be sensible to introduce (even if in a limited form) before we automate publishing.

I would also like to automate publishing the current master to @beta or @canary so we can get a heads up of any issues. I see @ndom91 has been using some Conventional Commits, I'd be happy to start doing that if we want to automate sticking to semver more strictly.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions