Skip to content

Publish Package to npmjs #23

Publish Package to npmjs

Publish Package to npmjs #23

name: Publish Package to npmjs
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install pnpm
run: npm install -g pnpm
- name: Install dependencies
run: pnpm install
build-lib:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install pnpm
run: npm install -g pnpm
- name: Install dependencies
run: pnpm install
- name: Build project with pnpm
run: pnpm webpack-build-lib
- name: Verify build output
run: ls -la dist
# Store the dist folder
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: app-build
path: dist
publish-npm:
needs: build-lib
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: app-build
path: dist
- run: ls -R
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}