Skip to content

update publish script #2

update publish script

update publish script #2

Workflow file for this run

name: Publish to npm
on:
push:
tags:
- 'v*'
jobs:
quality-checks:
name: Run Quality Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint
- name: Run type checking
run: npm run typecheck
- name: Run tests
run: npm run test:ci
- name: Build project
run: npm run build
- name: Validate package
run: npm run validate
publish:
name: Publish to npm
needs: quality-checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Extract version from tag
id: extract_version
run: |
TAG_NAME=${GITHUB_REF#refs/tags/v}
echo "version=$TAG_NAME" >> $GITHUB_OUTPUT
echo "Extracted version: $TAG_NAME"
- name: Update package.json version
run: |
npm version ${{ steps.extract_version.outputs.version }} --no-git-tag-version
git diff package.json
- name: Determine npm tag
id: npm_tag
run: |
VERSION=${{ steps.extract_version.outputs.version }}
if [[ "$VERSION" == *"alpha"* ]]; then
echo "tag=alpha" >> $GITHUB_OUTPUT
elif [[ "$VERSION" == *"beta"* ]]; then
echo "tag=beta" >> $GITHUB_OUTPUT
elif [[ "$VERSION" == *"rc"* ]]; then
echo "tag=rc" >> $GITHUB_OUTPUT
else
echo "tag=latest" >> $GITHUB_OUTPUT
fi
- name: Publish to npm
run: npm publish --tag ${{ steps.npm_tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Output published version
run: |
echo "✅ Successfully published react-enable@${{ steps.extract_version.outputs.version }}"
echo "📦 npm install react-enable@${{ steps.npm_tag.outputs.tag }}"