Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build, Test, and Publish to NPM

on:
push:
branches:
- '**'
tags:
- '*'
pull_request:
branches:
- '**'

jobs:
# 1. Test Job: Runs on all pushes and PRs
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Build project
run: npm run build

- name: Run tests
run: npm test

# 2. Release Job: Only runs on tags, after tests pass
build-and-release:
needs: test # Ensures tests pass before attempting to release
if: startsWith(github.ref, 'refs/tags/') # Only runs on tag pushes
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get Tag name
id: vars
run: echo "TAG_NAME=${GITHUB_REF_NAME}" >> $GITHUB_ENV

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- name: Install dependencies
run: npm ci

- name: Build project
run: npm run build

- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Loading