CI/CD Integration
Versionator integrates seamlessly with CI/CD pipelines for automated version management and releases.
note
These examples are illustrative and may need tweaking based on your specific CI/CD environment and requirements. Patches with fixes are welcome at github.com/benjaminabbitt/versionator.
Supported Platforms
| Platform | Description |
|---|---|
| GitHub Actions | Workflow automation for GitHub repositories |
| GitLab CI | Built-in CI/CD for GitLab |
| Azure DevOps | Microsoft's DevOps platform |
| Jenkins | Open-source automation server |
| CircleCI | Cloud-native CI/CD platform |
Common Patterns
Conditional Release
Only release on version tags:
# GitHub Actions
on:
push:
tags:
- 'v*'
Environment-specific Versions
- name: Set version
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
# Production: clean version
VERSION=$(versionator version)
else
# Development: add commit info
VERSION=$(versionator output version \
-t "{{MajorMinorPatch}}-{{EscapedBranchName}}.{{CommitsSinceTag}}")
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
Matrix Builds (Monorepo)
jobs:
build:
strategy:
matrix:
package: [core, utils, cli]
steps:
- name: Get package version
working-directory: packages/${{ matrix.package }}
run: echo "VERSION=$(versionator version)" >> $GITHUB_OUTPUT
Best Practices
- Install versionator in CI: Include installation step or use a pre-built image
- Cache binary: Cache the versionator binary to speed up builds
- Use output variables: Capture version once, use everywhere
- Tag-based releases: Trigger release workflows from Git tags
- Validate versions: Check VERSION file validity in CI
See Also
- Git Integration - Local Git workflows
- Makefiles and Just - Build tool integration