intall pnpm #8
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
name: Publish to NPM | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout code | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step 2: Setup Node.js (v20) and configure pnpm cache | |
- 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: Publish to NPM (on successful build) | |
- name: Publish to NPM | |
run: pnpm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# Step 8: Create GitHub Release (optional) | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
dist/** | |
# Step 9: Post-publish cleanup (optional) | |
- name: Post-publish cleanup | |
run: rm -rf dist |