Skip to content

A GH Action which determines if the package version is higher than the one on npm

License

Notifications You must be signed in to change notification settings

sandersn/npm-should-deploy-action

 
 

Repository files navigation

You want to deploy on merges to master, but think that can be a bit noisy. This action compares the version in package.json to see if the local one is higher and you can then deploy.

Here's an example of it in action:

name: Deploy to npm

on:
  push:
    branches:
      - main
      - master

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          registry-url: 'https://registry.npmjs.org'

      # Ensure everything is set up right
      - run: 'yarn install'
      - run: 'yarn build'
      - run: 'yarn test'

      - uses: orta/npm-should-deploy-action@master
        id: check

      - run: 'npm publish'
        if: ${{ steps.check.outputs.deploy == 'true' }}
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Basically a simpler version of orta/monorepo-deploy-nightly for single package repos.

Publish to a distribution branch

Actions are run from GitHub repos so we will check-in the packed dist folder.

Then run ncc and push the results:

$ npm run package
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1

Your action is now published! 🚀

See the versioning documentation

About

A GH Action which determines if the package version is higher than the one on npm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%