Auto Dev Release CI/CD Workflow
June 17, 2025 ยท View on GitHub
This repository includes an automated CI/CD workflow that publishes development versions to npm on every commit to the main branch. This enables dependent libraries to consume the latest changes without waiting for formal releases.
๐ How It Works
The Auto Dev Release workflow automatically:
- Triggers on every push to the
mainbranch - Runs tests to ensure code quality
- Bumps the dev version (e.g.,
3.1.0-dev.1โ3.1.0-dev.2) - Publishes to npm with the
devtag - Creates git tags for version tracking
๐ Prerequisites
Required Repository Secrets
The workflow requires the following repository secret to be configured:
NPM_TOKEN: npm automation token for publishing packages
How to Create NPM Token
- Log in to npmjs.com
- Go to Access Tokens in your account settings
- Click Generate New Token
- Select Automation token type
- Copy the generated token
- Add it as a repository secret named
NPM_TOKEN
๐ง Configuration
Package.json Requirements
Your package.json must include:
{
"name": "your-package-name",
"version": "1.0.0",
"scripts": {
"test": "your-test-command",
"build": "your-build-command"
}
}
Workflow Features
- Node.js 18 runtime environment
- npm ci for dependency installation
- Automated git configuration with github-actions bot
- Smart skipping for documentation-only changes
- Error handling and rollback capabilities
- 10-minute timeout to prevent hanging processes
๐ฆ Version Management
Dev Version Pattern
The workflow follows semantic versioning with dev suffixes:
- Base version:
3.1.0 - Dev versions:
3.1.0-dev.1,3.1.0-dev.2,3.1.0-dev.3, etc.
Version Increment Logic
- Extract base version from current
package.json - Check latest dev version published to npm
- Increment dev number by 1
- If no dev version exists, start with
dev.1
๐ฏ Usage for Consumers
Installing Dev Versions
# Install latest dev version
npm install doc-detective-common@dev
# Or in package.json
{
"dependencies": {
"doc-detective-common": "dev"
}
}
Checking Available Versions
# List all versions
npm view doc-detective-common versions
# Check current dev version
npm view doc-detective-common@dev version
๐ก๏ธ Safety Features
Automated Checks
- Test execution: All tests must pass before publishing
- Build validation: Build process must complete successfully
- Package.json validation: Ensures valid JSON and required fields
- Documentation skip: Skips release for docs-only changes
- Infinite loop prevention: Uses
[skip ci]in commit messages
Skip Conditions
The workflow will skip execution if:
- Commit message contains
[skip ci] - Commit message contains
Release - Event type is
release - Only documentation files were changed (
.md,.txt,.yml,.yaml,.github/)
๐ Troubleshooting
Common Issues
Publication fails with authentication error:
- Verify
NPM_TOKENsecret is correctly configured - Ensure token has automation permissions
- Check token hasn't expired
Version conflicts:
- Workflow automatically handles version increments
- If conflicts occur, manually increment and push
Tests failing:
- Fix failing tests before merge
- Workflow will not publish if tests fail
Manual Trigger
You can manually trigger the workflow:
- Go to Actions tab in GitHub
- Select Auto Dev Release workflow
- Click Run workflow
- Choose the
mainbranch
๐ Workflow Output
Successful Execution
โ
Tests passed
โ
Version bumped: 3.1.0-dev.1 โ 3.1.0-dev.2
โ
Published to npm with tag 'dev'
โ
Git tag 'v3.1.0-dev.2' created and pushed
Skipped Execution
โญ๏ธ Auto dev release skipped
๐ Only documentation changes detected
๐ Integration with Main Release Workflow
This workflow complements the existing release workflow:
- Auto Dev Release: Automatic dev versions on main branch commits
- Main Release: Manual stable releases through GitHub releases
- No conflicts: Workflows use different triggers and tags
๐ Benefits
- Faster iteration: Immediate availability of code changes
- Reduced bottlenecks: No manual release process required
- Better testing: Dev versions allow thorough testing before stable release
- Dependency management: Dependent repositories can consume latest changes instantly
๐ ๏ธ Extending the Workflow
Adding Notifications
Add Slack/Teams notifications by including notification steps:
- name: Notify team
uses: your-notification-action
with:
message: "๐ New dev release: v${{ steps.version.outputs.version }}"
Cross-Repository Updates
Extend to automatically update dependent repositories by adding repository dispatch events.
For more information about the implementation, see the workflow file: .github/workflows/auto-dev-release.yml