Skip to content

Merge pull request #2 from Atlantis-Systems/claude/fix-npm-install-Or4ly #7

Merge pull request #2 from Atlantis-Systems/claude/fix-npm-install-Or4ly

Merge pull request #2 from Atlantis-Systems/claude/fix-npm-install-Or4ly #7

Workflow file for this run

name: Publish to NPM
on:
push:
branches:
- main
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Configure git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Bump version and create tag
id: version
run: |
# Get the current version
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "Current version: $CURRENT_VERSION"
# Determine version bump type based on commit messages
if git log --format=%B -n 1 | grep -q "BREAKING CHANGE\|!:"; then
BUMP_TYPE="major"
elif git log --format=%B -n 1 | grep -q "^feat"; then
BUMP_TYPE="minor"
else
BUMP_TYPE="patch"
fi
echo "Bump type: $BUMP_TYPE"
# Bump version
NEW_VERSION=$(npm version $BUMP_TYPE --no-git-tag-version)
echo "New version: $NEW_VERSION"
# Commit version bump
git add package.json
git commit -m "chore: bump version to $NEW_VERSION"
# Create and push tag
git tag $NEW_VERSION
git push origin main
git push origin $NEW_VERSION
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.version }}
release_name: Release ${{ steps.version.outputs.version }}
draft: false
prerelease: false