carvalholeo/generator-dh

View on GitHub
.github/workflows/npm-publish.yml

Summary

Maintainability
Test Coverage
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Linux / NPM Publish

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-18.04
        node_version:
          - 10
          - 11
          - 12
          - 13
          - 14
          - 15
        architecture:
          - x64
    name:  Node V${{ matrix.node_version }} on ${{ matrix.os }}/${{ matrix.architecture }}
    steps:
      - uses: actions/checkout@v2
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: 2.6
      - run: gem update --system
      - run: gem install compass
      - uses: actions/setup-node@v2
        with:
          node-version: ${{ matrix.node_version }}
          architecture: ${{ matrix.architecture }}
      - run: npm rebuild
      - run: npm install-test
      - run: npm run lint

  publish-npm:
    if: ${{ github.ref == 'refs/heads/main' }}
    needs: build
    runs-on: ubuntu-latest
    name: Publish package on NPM Registry
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 12
          registry-url: https://registry.npmjs.org/
      - run: npm install
      - run: npm run build
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.npm_token}}