Skip to content

Publish SEO Master to npm #10

Publish SEO Master to npm

Publish SEO Master to npm #10

Workflow file for this run

name: Publish SEO Master to npm
on:
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v4
# Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
cache: "npm"
# Add npm authentication for publishing
- name: Authenticate with npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
# Install dependencies
- name: Install dependencies
run: npm install
# Build the project
- name: Build the project
run: npm run build
# Verify version change in package.json
- name: Check if version has changed
id: version-check
run: |
NEW_VERSION=$(node -p "require('./package.json').version")
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
# Publish to npm if it's a new version and a tagged release
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Clean up after the build
- name: Clean node_modules
run: rm -rf node_modules