Skip to content

Refactor CI configuration to restrict Node.js versions to 22.x and co… #32

Refactor CI configuration to restrict Node.js versions to 22.x and co…

Refactor CI configuration to restrict Node.js versions to 22.x and co… #32

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [main, master]
tags:
- 'v*'
pull_request:
branches: [main, master]
workflow_dispatch:
jobs:
lint-and-typecheck:
name: Lint and TypeCheck
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
- name: TypeScript type checking
run: npm run typecheck
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Upload coverage reports
uses: codecov/codecov-action@v4
if: matrix.node-version == '20.x' && github.event_name != 'pull_request'
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
build:
name: Build
runs-on: ubuntu-latest
needs: [lint-and-typecheck, test]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build package
run: npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 7
publish:
name: Publish to npm
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))
environment: npm-publish
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Install dependencies
run: npm ci
- name: Publish to NPM
if: startsWith(github.ref, 'refs/tags/v')
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}