Optimize Your CI/CD Pipeline
Get instant insights into your CI/CD performance and costs. Reduce build times by up to 45% and save on infrastructure costs.
name: Bump version
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
github-tag-action
This action automatically bumps and tags the version on GitHub using semantic versioning.
What is GitHub Tag Action?β
The GitHub Tag Action helps automate version bumping and tagging on the master branch using the latest semantic version format. It ensures that every merge to master results in a correctly tagged version.
How to Use github_token
β
To authorize the action to tag the repository, you need to provide the GitHub token.
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
You can learn more about creating GitHub tokens in the GitHub Token Documentation.
How to Fetch All Tagsβ
By default, this action fetches the last 100 tags. If you need all tags, use the fetch_all_tags
input.
with:
fetch_all_tags: true
How to Filter Branches for Releaseβ
You can specify which branches will trigger a release using release_branches
.
with:
release_branches: 'master,release/*'
How to Customize Tag Creationβ
To customize the tag creation process, you can use the following inputs:
-
default_bump
: Specify whether to bump apatch
,minor
, ormajor
version.
Example:with:
default_bump: 'minor' -
custom_tag
: Set a custom tag name instead of using the default semantic versioning.with:
custom_tag: 'v1.0.0'
How to Append to Pre-Release Tagsβ
You can add a suffix to the pre-release tag using append_to_pre_release_tag
:
with:
append_to_pre_release_tag: 'beta'
How to Customize Commit Messages and Changelog Sectionsβ
You can define custom rules for the commit messages that determine the release type. Hereβs an example of custom release rules:
with:
custom_release_rules: 'fix:patch,feat:minor,breaking:major'
How to Perform a Dry Runβ
If you want to test the action without actually tagging the repository, use the dry_run
option.
with:
dry_run: true
This will calculate the next version and changelog without performing any actual tagging.
Outputsβ
new_tag
: The newly created tag value.new_version
: The new version number without the prefix.previous_tag
: The previous tag value.changelog
: The changelog generated between the current and previous tags.