A GitHub Composite Action that automatically determines version bump types from Conventional Commits and calculates the new semantic version for Helm charts.
- π Automatic Detection: Analyzes commit messages to determine the appropriate version bump
- π Conventional Commits Support: Recognizes
feat,fix, and breaking change patterns - ποΈ Manual Override: Allows explicit version bump type via input
- π Helm Chart Integration: Reads current version directly from
Chart.yaml - π Semantic Versioning: Follows SemVer 2.0.0 specification
| Commit Pattern | Bump Type | Example |
|---|---|---|
feat!: or BREAKING CHANGE |
major | 1.2.3 β 2.0.0 |
feat: or feature: |
minor | 1.2.3 β 1.3.0 |
| All other commits | patch | 1.2.3 β 1.2.4 |
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for commit history analysis
- name: Bump Version
id: version
uses: your-org/semver-bump-action@v1
with:
chart-path: charts/my-chart
- name: Print Versions
run: |
echo "Current: ${{ steps.version.outputs.current-version }}"
echo "Bump type: ${{ steps.version.outputs.bump-type }}"
echo "New: ${{ steps.version.outputs.new-version }}"on:
workflow_dispatch:
inputs:
version_bump:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bump Version
id: version
uses: your-org/semver-bump-action@v1
with:
chart-path: charts/my-chart
version-bump: ${{ inputs.version_bump }}If the action is stored in your repository under .github/actions/semver-bump/:
- name: Bump Version
id: version
uses: ./.github/actions/semver-bump
with:
chart-path: charts/my-chartname: Release Helm Chart
on:
push:
branches: [main]
paths:
- 'charts/**'
workflow_dispatch:
inputs:
version_bump:
description: 'Version bump type'
required: false
type: choice
options:
- ''
- patch
- minor
- major
env:
CHART_PATH: charts/my-chart
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Bump Version
id: version
uses: your-org/semver-bump-action@v1
with:
chart-path: ${{ env.CHART_PATH }}
version-bump: ${{ inputs.version_bump }}
- name: Update Chart.yaml
run: |
sed -i "s/^version:.*/version: ${{ steps.version.outputs.new-version }}/" \
${{ env.CHART_PATH }}/Chart.yaml
- name: Commit and Tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add ${{ env.CHART_PATH }}/Chart.yaml
git commit -m "chore: bump chart version to ${{ steps.version.outputs.new-version }}"
git tag "v${{ steps.version.outputs.new-version }}"
git push origin main --tags
- name: Package and Push Chart
run: |
helm package ${{ env.CHART_PATH }}
helm push *.tgz oci://ghcr.io/${{ github.repository_owner }}/charts| Input | Description | Required | Default |
|---|---|---|---|
chart-path |
Path to the Helm chart directory containing Chart.yaml |
β | - |
version-bump |
Manual version bump type (major, minor, patch). If empty, auto-detection is used. |
β | '' |
commit-count |
Number of recent commits to analyze for auto-detection | β | 10 |
| Output | Description | Example |
|---|---|---|
current-version |
The current version extracted from Chart.yaml |
1.2.3 |
bump-type |
The determined or specified bump type | minor |
new-version |
The calculated new semantic version | 1.3.0 |
- The target
Chart.yamlmust contain aversion:field in standard format - For auto-detection: repository must be checked out with
fetch-depth: 0or sufficient depth - Git must be available in the runner environment
This action recognizes the following commit message patterns:
# Major version bump (breaking changes)
feat!: remove deprecated API endpoints
feat(api)!: change authentication flow
chore: update dependencies
BREAKING CHANGE: API v1 is no longer supported
# Minor version bump (new features)
feat: add user profile endpoint
feature: implement dark mode
feat(auth): add OAuth2 support
# Patch version bump (fixes, chores, etc.)
fix: resolve memory leak in worker
docs: update installation guide
chore: upgrade dependencies
refactor: simplify error handling
style: format code with prettier
test: add unit tests for auth moduleuses: your-org/semver-bump-action@v1-
Create the directory structure:
mkdir -p .github/actions/semver-bump
-
Create
.github/actions/semver-bump/action.yml:name: 'Semantic Version Bump' description: 'Determines version bump type from conventional commits and calculates new version' inputs: chart-path: description: 'Path to the Helm chart directory' required: true version-bump: description: 'Manual version bump type (major, minor, patch)' required: false default: '' commit-count: description: 'Number of commits to analyze' required: false default: '10' outputs: current-version: description: 'The current version from Chart.yaml' value: ${{ steps.current_version.outputs.version }} bump-type: description: 'The determined bump type' value: ${{ steps.bump_type.outputs.type }} new-version: description: 'The calculated new version' value: ${{ steps.new_version.outputs.version }} runs: using: 'composite' steps: - name: Get current version id: current_version shell: bash run: | CURRENT_VERSION=$(grep '^version:' ${{ inputs.chart-path }}/Chart.yaml | awk '{print $2}') echo "version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT - name: Determine version bump type id: bump_type shell: bash run: | if [ -n "${{ inputs.version-bump }}" ]; then echo "type=${{ inputs.version-bump }}" >> $GITHUB_OUTPUT else COMMITS=$(git log --format=%s -n ${{ inputs.commit-count }}) if echo "$COMMITS" | grep -qE "^(feat|feature)!:|BREAKING CHANGE"; then echo "type=major" >> $GITHUB_OUTPUT elif echo "$COMMITS" | grep -qE "^(feat|feature):"; then echo "type=minor" >> $GITHUB_OUTPUT else echo "type=patch" >> $GITHUB_OUTPUT fi fi - name: Bump version id: new_version shell: bash run: | CURRENT="${{ steps.current_version.outputs.version }}" BUMP_TYPE="${{ steps.bump_type.outputs.type }}" IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT" case $BUMP_TYPE in major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; minor) MINOR=$((MINOR + 1)); PATCH=0 ;; patch) PATCH=$((PATCH + 1)) ;; esac echo "version=${MAJOR}.${MINOR}.${PATCH}" >> $GITHUB_OUTPUT
-
Reference it in your workflows:
uses: ./.github/actions/semver-bump
Ensure your Chart.yaml has the version field at the start of a line:
version: 1.2.3 # β
Correct
version: 1.2.3 # β Indented - won't be detected- Check that commits follow Conventional Commits format
- Ensure repository is checked out with sufficient history:
- uses: actions/checkout@v4 with: fetch-depth: 0 # Full history
This action requires Git to be available. All GitHub-hosted runners include Git by default.
MIT License - see LICENSE for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request