This guide explains how to set up and use the automated CI/CD pipeline for the glin-profanity package.
- GitHub Repository Secrets
- Branch Structure
- Node.js 18+ for development
Add these secrets in your GitHub repository settings (Settings > Secrets and variables > Actions):
-
NPM_TOKEN(Required for publishing)# Generate an npm token at https://www.npmjs.com/settings/tokens # Choose "Automation" token type # Copy the token and add it as a GitHub secret
-
CODECOV_TOKEN(Optional, for coverage reporting)# Get token from https://codecov.io/ # Add your repository and copy the token
- Go to npmjs.com and log in
- Navigate to Access Tokens in your account settings
- Click Generate New Token > Automation
- Copy the token (it starts with
npm_...) - In GitHub: Settings > Secrets and variables > Actions > New repository secret
- Name:
NPM_TOKEN, Value: your token
main (development)
├── feature/new-feature
├── bugfix/issue-123
└── release (production-ready)
└── Tagged releases (v2.1.0, etc.)
-
main: Main development branch- All feature PRs target this branch
- CI runs on every PR and push
- Beta releases can be published from here
-
release: Production release branch- Only merge to this when ready for release
- Requires
publishlabel on PR to trigger release - Triggers semantic versioning and npm publishing
Triggers:
- Pull requests to
mainorrelease/** - Pushes to
main
What it does:
- ✅ TypeScript type checking
- 🏗️ Builds both CommonJS and ESM versions
- 🧪 Runs Jest tests with coverage
- 📊 Uploads coverage to Codecov
- 🔒 Security audit with npm audit
- 💾 Creates build artifacts
Triggers:
- Manual workflow dispatch
- PR with
publishlabel merged toreleasebranch
What it does:
- 🔍 Validates release conditions
- 🧪 Runs comprehensive tests
- 📦 Publishes to npm using semantic-release
- 🏷️ Creates git tags
- 📝 Generates changelog
- 🎉 Creates GitHub release
-
Create a feature branch:
git checkout main git pull origin main git checkout -b feature/my-new-feature
-
Make changes and commit:
# Make your changes git add . git commit -m "feat: add new context-aware filtering"
-
Push and create PR:
git push origin feature/my-new-feature # Create PR on GitHub targeting 'main' -
CI automatically runs:
- Tests must pass
- Coverage is reported
- Build artifacts are created
-
Merge feature to main:
# PR gets merged to main -
Create release PR:
git checkout release git pull origin release git merge main git push origin release # Create PR from release to release (for tracking) -
Add
publishlabel:- Go to the PR on GitHub
- Add the
publishlabel - Merge the PR
-
Automatic release:
- Semantic-release analyzes commits
- Determines version bump (patch/minor/major)
- Publishes to npm
- Creates GitHub release
- Go to Actions tab in GitHub
- Select "🚀 Release & Publish" workflow
- Click "Run workflow"
- Choose version bump type:
patch: Bug fixes (2.1.0 → 2.1.1)minor: New features (2.1.0 → 2.2.0)major: Breaking changes (2.1.0 → 3.0.0)
- Optional: Enable dry run for testing
Use Conventional Commits for automatic versioning:
# Features (minor version bump)
git commit -m "feat: add context-aware profanity filtering"
git commit -m "feat(api): add new configuration options"
# Bug fixes (patch version bump)
git commit -m "fix: resolve memory leak in filter"
git commit -m "fix(build): correct ESM export paths"
# Breaking changes (major version bump)
git commit -m "feat!: redesign API for better performance"
git commit -m "feat(core)!: remove deprecated methods"
# Other types (no version bump)
git commit -m "docs: update README with new examples"
git commit -m "test: add more context-aware tests"
git commit -m "chore: update dependencies"
git commit -m "style: fix linting issues"| Type | Example | Version Bump |
|---|---|---|
feat |
New features | Minor (2.1.0 → 2.2.0) |
fix |
Bug fixes | Patch (2.1.0 → 2.1.1) |
perf |
Performance improvements | Patch (2.1.0 → 2.1.1) |
feat! or BREAKING CHANGE: |
Breaking changes | Major (2.1.0 → 3.0.0) |
docs, test, chore |
No release | No bump |
Create these labels in your repository for better workflow management:
# Release labels
publish # 🚀 Triggers release when PR is merged
breaking # ⚠️ Indicates breaking changes
enhancement # ✨ New features
bug # 🐛 Bug fixes
documentation # 📚 Documentation updates
security # 🔒 Security fixes
# Status labels
ready-for-review # ✅ PR is ready for review
work-in-progress # 🚧 Still being worked on
needs-testing # 🧪 Requires additional testing- Codecov: Automatic coverage reporting
- Artifacts: Coverage reports available in workflow runs
- Build outputs: CommonJS and ESM builds
- Test results: Jest test results and coverage
- Package files: Ready-to-publish npm package
- npm package: Published to npmjs.com
- GitHub releases: Tagged releases with changelogs
- Git tags: Semantic version tags
-
Tests failing in CI but passing locally
# Run tests exactly like CI npm run test:ci -
Build failing in CI
# Check TypeScript errors npx tsc --noEmit # Run both builds npm run build
-
Semantic release not working
- Check commit message format
- Ensure
NPM_TOKENsecret is set - Verify branch is
release
-
NPM publish permission denied
- Verify
NPM_TOKENis valid - Check npm package ownership
- Ensure token has publish permissions
- Verify
# Check package before publishing
npm pack --dry-run
# Validate semantic-release locally
npx semantic-release --dry-run
# Test workflow locally (with act)
act -j test
# Check coverage locally
npm run test:coverage# 1. Create fix branch
git checkout -b fix/memory-leak main
# 2. Make fix and commit
git commit -m "fix: resolve memory leak in context analyzer"
# 3. Create PR to main → CI runs
# 4. Merge PR to main
# 5. Create release PR to release branch
# 6. Add 'publish' label and merge
# Result: 2.1.0 → 2.1.1# 1. Create feature branch
git checkout -b feat/new-language-support main
# 2. Implement feature
git commit -m "feat: add Spanish language support"
# 3. Create PR to main → CI runs
# 4. Merge PR to main
# 5. Create release PR to release branch
# 6. Add 'publish' label and merge
# Result: 2.1.0 → 2.2.0# 1. Create breaking change branch
git checkout -b feat/api-redesign main
# 2. Implement breaking changes
git commit -m "feat!: redesign Filter API for better performance
BREAKING CHANGE: Filter constructor options have changed.
See migration guide for details."
# 3. Create PR to main → CI runs
# 4. Merge PR to main
# 5. Create release PR to release branch
# 6. Add 'publish' label and merge
# Result: 2.1.0 → 3.0.0# 1. Go to GitHub Actions
# 2. Select "🚀 Release & Publish"
# 3. Click "Run workflow"
# 4. Select branch: release
# 5. Choose: patch (for hotfix)
# 6. Leave dry_run: false
# 7. Click "Run workflow"
# Result: Immediate release-
Always test locally first:
npm run build && npm run test:ci -
Use conventional commits for automatic versioning
-
Keep the release branch clean:
- Only merge when ready for production
- Use
publishlabel intentionally
-
Monitor the CI/CD:
- Check workflow status
- Review build artifacts
- Watch coverage trends
-
Use dry runs for testing:
- Test manual releases with
dry_run: true - Verify semantic-release with
--dry-run
- Test manual releases with
If you encounter issues with the CI/CD setup:
- Check the GitHub Actions logs
- Review the troubleshooting section
- Open an issue with the
ci/cdlabel
Happy Releasing! 🚀