GitHub Action to calculate the next semantic version from commit history.
Supports push and pull_request contexts.
tag-prefix(optional, default:"")- Prefix for git tags, e.g.
vfor tags likev0.3.7.
- Prefix for git tags, e.g.
working-directory(optional, default:.)- Directory where git commands should run.
- If this points to a subdirectory inside the repository, only commits that touched this subpath are considered.
next-version: version without prefix, e.g.0.4.0next-tag: version with prefix, e.g.v0.4.0bump-type: one ofmajor,minor,patchcommit-count: number of commits evaluated
feat:->minor(x.Y.0)- any other conventional commit type (e.g.
chore:,fix:) ->patch(x.y.Z) - non-conventional commit messages ->
patch(never fails because of message format) !orBREAKING CHANGE:->major
name: Release version calc
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Calculate next version
id: version
uses: ./
with:
tag-prefix: v
working-directory: .
- name: Show
run: |
echo "next-version=${{ steps.version.outputs.next-version }}"
echo "next-tag=${{ steps.version.outputs.next-tag }}"
echo "bump-type=${{ steps.version.outputs.bump-type }}"
echo "commit-count=${{ steps.version.outputs.commit-count }}"- For correct tag and history detection, use
fetch-depth: 0in checkout. - The action intentionally does not implement prerelease semantics.
- The repository includes a workflow test in
.github/workflows/test-action.yml. - It validates:
- subpath filtering via
working-directory - root repository behavior
- non-conventional commit fallback to patch bump
- subpath filtering via
- Unit tests use the built-in Node test runner.
- Run locally with:
node --test