👷 Added CI and CD for build, test and publishing #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18, 20, 22] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: bun install --frozen-lockfile | |
- name: Run tests | |
run: bun test | |
- name: Type check | |
run: bun run tsc --noEmit | |
- name: Build package | |
run: bun run build | |
- name: Check build artifacts | |
run: | | |
if [ ! -d "dist" ]; then | |
echo "Build failed: dist directory not found" | |
exit 1 | |
fi | |
if [ ! -f "dist/index.js" ]; then | |
echo "Build failed: dist/index.js not found" | |
exit 1 | |
fi | |
if [ ! -f "dist/index.d.ts" ]; then | |
echo "Build failed: dist/index.d.ts not found" | |
exit 1 | |
fi | |
echo "Build artifacts verified successfully" | |
# Test with Node.js as well to ensure compatibility | |
test-node: | |
name: Test with Node.js | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18, 20, 22] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
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: Type check | |
run: npx tsc --noEmit | |
- name: Build package | |
run: npm run build |