Skip to content

add: publish package #17

add: publish package

add: publish package #17

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Node.js CI
on:
push:
branches: ['main']
pull_request:
branches: ['main']
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: 'node_modules'
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('yarn.lock') }}
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Add artifact to github
uses: actions/upload-artifact@v2
with:
name: artifact
path: dist
test:
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v3
with:
path: 'node_modules'
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('yarn.lock') }}
- run: yarn install --frozen-lockfile
- run: yarn lint
- name: Download build
uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- run: yarn test
npm-publish:
needs: [build, test]
name: npm-publish
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
strategy:
matrix:
os: [ubuntu-latest]
node-version: [18.x]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Download build
uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- run: yarn release:package
- run: ls -lisha release
- run: npm publish release --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}