Skip to content

Commit

Permalink
Added github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
travisvn committed Oct 28, 2024
1 parent 22df533 commit 48cf9fa
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build

on:
# Trigger the workflow on push to main branch
push:
branches:
- main
# Trigger the workflow on pull request events
pull_request:
branches:
- main

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v3

# Step 2: Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

# Step 3: Install dependencies
- name: Install dependencies
run: npm install

# Step 4: Run build
- name: Build package
run: npm run build

# Step 5: Run tests
- name: Run tests
run: npm run test

# Step 6: Verify type definitions
- name: Check TypeScript declarations
run: tsc --noEmit
65 changes: 65 additions & 0 deletions .github/workflows/nodejs-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Node.js Package

on:
push:
tags:
- '*' # Trigger when any tag is pushed

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest

steps:
# Step 1: Check out the code
- uses: actions/checkout@v3

# Step 2: Set up Node.js
- uses: actions/setup-node@v3
with:
node-version: '20'

# Step 3: Cache npm dependencies
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# Step 4: Install dependencies
- run: npm install

# Step 5: Run build script
- run: npm run build

# Step 6: Run tests
- run: npm run test

publish-npm:
name: Publish to npm
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') # Ensure only runs on tag push

steps:
# Step 1: Check out the code
- uses: actions/checkout@v3

# Step 2: Set up Node.js and npm registry
- uses: actions/setup-node@v3
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org/'

# Step 3: Install dependencies
- run: npm install

# Step 4: Run build script (ensures built files are up-to-date)
- run: npm run build

# Step 5: Publish to npm
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 48cf9fa

Please sign in to comment.