A GitHub action that calculates the next semantic version number based on existing GitHub releases.
- 🏷️ Release-based versioning: Uses GitHub releases (not git tags) to determine current version
- 📈 Semantic versioning: Supports major.minor.patch version bumping
- 🔧 Flexible prefixes: Optional version prefixes (like 'v1.0.0')
- 🚀 Zero setup: Works out of the box with GitHub CLI
- ✨ Smart defaults: Handles edge cases like no existing releases or invalid version formats
- name: Get next version
id: version
uses: eveenendaal/github-actions/actions/get-next-version@master
- name: Show version info
run: |
echo "Current version: ${{ steps.version.outputs.current-version }}"
echo "Next version: ${{ steps.version.outputs.next-version }}"- name: Get next version with 'v' prefix
id: version
uses: eveenendaal/github-actions/actions/get-next-version@master
with:
version-prefix: 'v'
bump-type: 'minor'
- name: Create release
run: |
gh release create "v${{ steps.version.outputs.next-version }}" \
--title "Release v${{ steps.version.outputs.next-version }}" \
--notes "Automated release"# Bump patch version (default)
- uses: eveenendaal/github-actions/actions/get-next-version@master
with:
bump-type: 'patch' # 1.0.0 -> 1.0.1
# Bump minor version
- uses: eveenendaal/github-actions/actions/get-next-version@master
with:
bump-type: 'minor' # 1.0.0 -> 1.1.0
# Bump major version
- uses: eveenendaal/github-actions/actions/get-next-version@master
with:
bump-type: 'major' # 1.0.0 -> 2.0.0| Input | Description | Required | Default |
|---|---|---|---|
version-prefix |
Prefix for version tags (e.g., 'v'). Leave empty for no prefix. | No | '' |
bump-type |
Which part to bump: major, minor, or patch |
No | patch |
| Output | Description |
|---|---|
next-version |
The calculated next version number (without prefix) |
current-version |
The current/latest version found (empty if no releases exist) |
- Fetches releases: Uses GitHub CLI to get the latest release from your repository
- Parses version: Extracts semantic version from the release tag (supports optional prefix)
- Calculates next: Increments the appropriate version part based on
bump-type - Handles edge cases:
- No releases → starts with appropriate initial version (0.0.1, 0.1.0, or 1.0.0)
- Invalid format → resets to initial version
- Respects version prefixes in input but outputs clean version numbers
patchbump →0.0.1minorbump →0.1.0majorbump →1.0.0
patch:1.2.3→1.2.4minor:1.2.3→1.3.0major:1.2.3→2.0.0
- GitHub CLI (
gh) must be available (standard in GitHub Actions runners) - Repository must have appropriate permissions to read releases
name: Release
on:
push:
branches: [main]
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Calculate next version
id: version
uses: eveenendaal/github-actions/actions/get-next-version@master
with:
version-prefix: 'v'
bump-type: 'patch'
- name: Update package.json
run: |
npm version ${{ steps.version.outputs.next-version }} --no-git-tag-version
- name: Commit version bump
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add package.json
git commit -m "Bump version to ${{ steps.version.outputs.next-version }}"
git push
- name: Create release
run: |
gh release create "v${{ steps.version.outputs.next-version }}" \
--title "Release v${{ steps.version.outputs.next-version }}" \
--generate-notesThis action differs from typical git tag-based versioning tools:
- ✅ Uses GitHub releases instead of git tags
- ✅ Read-only: Doesn't modify your repository files
- ✅ Flexible: Supports different bump types and prefixes
- ✅ Robust: Handles edge cases gracefully
Perfect for workflows where you want to calculate the next version before actually creating a release or updating files.