Skip to content

Commit

Permalink
.npmignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Gajesh2007 committed Feb 2, 2025
1 parent ce96557 commit 02e3eb9
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 2 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: CI
on:
push:
branches: [ main, master ]
tags:
- 'v*'
pull_request:
branches: [ main, master ]

Expand Down Expand Up @@ -38,10 +40,15 @@ jobs:
- name: Build
run: npm run build

- name: Upload coverage reports
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

publish:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
if: startsWith(github.ref, 'refs/tags/v')

steps:
- uses: actions/checkout@v3
Expand All @@ -58,6 +65,20 @@ jobs:
- name: Build
run: npm run build

- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: Release ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to npm
run: npm publish
env:
Expand Down
25 changes: 25 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Source
src/
examples/
tests/

# Development files
.github/
.vscode/
.idea/
.git/
.gitignore
.npmignore
.env*
jest.config.js
tsconfig.json
.eslintrc.js
.prettierrc

# Build artifacts
coverage/
*.log
*.tsbuildinfo

# Keep dist folder
!dist/
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"clean": "rm -rf dist",
"example:basic": "ts-node examples/basic-usage.ts",
"example:advanced": "ts-node examples/advanced-usage.ts",
"docs": "typedoc --out docs src/index.ts"
"docs": "typedoc --out docs src/index.ts",
"release": "./scripts/release.sh"
},
"repository": {
"type": "git",
Expand Down
33 changes: 33 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Ensure we're in a clean state
if [[ -n $(git status -s) ]]; then
echo "Error: Working directory is not clean. Please commit or stash changes first."
exit 1
fi

# Get current version from package.json
current_version=$(node -p "require('./package.json').version")
echo "Current version: $current_version"

# Ask for new version
read -p "Enter new version (current is $current_version): " new_version

# Validate version format
if ! [[ $new_version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
echo "Error: Version must be in format x.y.z or x.y.z-tag"
exit 1
fi

# Update version in package.json
npm version $new_version -m "Release v%s"

# Push changes and tags
git push origin master
git push origin v$new_version

echo "Release v$new_version initiated!"
echo "GitHub Actions will now:"
echo "1. Run tests"
echo "2. Create a GitHub release"
echo "3. Publish to npm"

0 comments on commit 02e3eb9

Please sign in to comment.