-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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 |
This file contains 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
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 }} |