-
Notifications
You must be signed in to change notification settings - Fork 1
51 lines (41 loc) · 1.31 KB
/
publish-to-npm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Publish to NPM
on:
push:
tags:
- '*' # Triggers on all tag pushes
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout code
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Setup Node.js (v20)
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
# Step 3: Install pnpm
- name: Install pnpm
run: |
npm install -g pnpm
pnpm --version # Verify that pnpm is installed and accessible
# Step 4: Install dependencies using pnpm
- name: Install dependencies
run: pnpm install
# Step 5: Run tests (replace with your actual test command)
- name: Run tests
run: pnpm run test
# Step 6: Build the library (replace with your actual build command)
- name: Build the library
run: pnpm run build
# Step 7: Set version to the Git tag version
- name: Set NPM version from Git tag
run: |
TAG_NAME=${GITHUB_REF#refs/tags/} # Extract tag name from GITHUB_REF
npm version "$TAG_NAME" --no-git-tag-version # Set npm version to tag name without creating a new git tag
# Step 8: Publish to NPM (on successful build)
- name: Publish to NPM
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}