Skip to content

Commit 0af7a11

Browse files
committed
V1
1 parent 8c5c6ac commit 0af7a11

2 files changed

Lines changed: 39 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626

2727
- name: Install dependencies
2828
run: |
29-
npm ci # Installs dependencies based on the lockfile (package-lock.json)
29+
npm install # Installs dependencies
3030
3131
- name: Build the library
3232
run: npm run build # Runs your build script from package.json

.github/workflows/release.yml

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,60 @@
1-
name: Release - Test, Build, Publish
1+
name: Build, Test, and Publish Library
22

33
on:
4-
release:
5-
types: [created] # Triggers when a new release is created
4+
pull_request:
5+
branches:
6+
- v1 # or whatever branch you want to test PRs against
7+
push:
8+
tags:
9+
- 'v*.*.*' # trigger on new version tags for publishing to npm
610

711
jobs:
8-
test_build_publish:
12+
test:
913
runs-on: ubuntu-latest
1014
strategy:
1115
matrix:
12-
node-version: [14, 18, 23] # Test on Node.js versions 14, 18, and 23
13-
16+
node-version: [14, 18, 23] # Define the Node.js versions to test on
17+
1418
steps:
1519
- name: Checkout repository
16-
uses: actions/checkout@v2
20+
uses: actions/checkout@v2 # Checkout code
1721

1822
- name: Set up Node.js
1923
uses: actions/setup-node@v3
2024
with:
21-
node-version: ${{ matrix.node-version }} # Use the Node.js version from the matrix
25+
node-version: ${{ matrix.node-version }} # Use the version from the matrix
2226

2327
- name: Install dependencies
24-
run: |
25-
npm ci # Installs dependencies based on the lockfile (package-lock.json)
28+
run: npm ci # Install dependencies from the lockfile
2629

2730
- name: Build the library
28-
run: npm run build # Runs your build script from package.json
31+
run: npm run build # Assuming you have a build script in package.json
2932

3033
- name: Run tests
31-
run: npm test # Runs your test command
34+
run: npm test # Run your tests
35+
36+
publish:
37+
runs-on: ubuntu-latest
38+
needs: test # Ensure the tests are run first
39+
if: startsWith(github.ref, 'refs/tags/v') # Only run this on new version tags
40+
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v2
44+
45+
- name: Set up Node.js
46+
uses: actions/setup-node@v3
47+
with:
48+
node-version: 18 # Use any version (this is just for publishing)
49+
50+
- name: Install dependencies
51+
run: npm ci # Install dependencies from the lockfile
52+
53+
- name: Build the library
54+
run: npm run build # Build your library
3255

3356
- name: Publish to npm
57+
run: npm publish --access public # Publish to npm
58+
3459
env:
35-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # Make sure to set NPM_TOKEN as a secret in GitHub
36-
run: npm publish --access public # Publishes the package to npm
60+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # Ensure the token is set in GitHub Secrets

0 commit comments

Comments
 (0)