Skip to content

Commit

Permalink
ci: add workflows for ci, pr & publish
Browse files Browse the repository at this point in the history
  • Loading branch information
ram-amoncar committed May 11, 2024
1 parent 86e0a59 commit 338daa4
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Continuous Integration

on:
push:
branches: [main]
paths: [src/**, tests/**, package.json]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Installing dependencies ⚒️
run: npm ci

- name: Running tests 🧪
run: npm run test
46 changes: 46 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Pull Request Check
on:
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Installing dependencies ⚒️
run: npm ci

- name: Running Tests 🧪
run: npm run test

lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Installing dependencies ⚒️
run: npm ci

- name: Checking code quality 🤔
run: npm run lint
50 changes: 50 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish to NPM 📦
on:
release:
types: [created]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Installing dependencies ⚒️
run: npm ci

- name: Running tests 🧪
run: npm run test

build:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies ⚒️
run: npm ci

- name: Building 🔧
run: npm run build

- name: Publish package on NPM 📦
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "npm-package-template",
"version": "1.2.4",
"version": "1.3.0",
"description": "A template for NPM package in Typescript",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down

0 comments on commit 338daa4

Please sign in to comment.