GitHub Action
git-next-tag
This tool generates a new git tag from those already in your project git history.
Tag calculation is based on conventional commit and semantic versioning.
I wanted a simple tool with very little configuration that would guarantee the consistency of the versions included the git tags of my projects.
I had not found a tool that do the followings tasks combined in an elegant way:
- Follows conventional commit specifications with the greatest assiduity.
- Uses semantic versioning for non-JavaScript based projects.
- Manage project versioning and release cycle using Git as source of truth.
- Implements a CI without a config file, only via GitHub Actions and Git configuration.
- Can handle ZeroVer and SemVer with a minimum of automation.
- Manages an opinionated logic on SemVer prerelease increments.
Maybe it does exist. If in doubt, give this project a try. 😉
- The current branch using the Action MUST have a linear git history.
- Before the first start, it is necessary to add a version tag in the git-history consistent with the action configuration.
Example of command to create a git tag on the first commit of a project:
git switch main
git tag v0.0.0 $(git rev-list --max-parents=0 HEAD)
git push origin v0.0.0
- This action needs to retrieve the entire git history of the project using to
actions/checkout
. contents: read
permission is required to access the repository content in order to retrieve git-related information (commits, tags, etc).
Here's an example configuration:
jobs:
get-new-tag:
runs-on: ['ubuntu-latest']
timeout-minutes: 5
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: calculate_next_version
uses: ldelarue/git-next-tag@v0
with:
tag-prefix: v
- shell: bash
run: |
echo "::notice::Generated tag is '${{ steps.calculate_next_version.outputs.tag }}'"
Tip
Please read action.yml for more details on parameters and output values.
In this example:
- My only tag in my git history is
v0.0.0
. - I pushed a commit named
feat: this is an example
that triggered this job.
So the resulted tag is v0.1.0
.
Give it a try! And see what your Action prints in its logs! 🚀
- It is highly recommended to read at least once the Conventional Commits and Semantic Versioning specifications to better understand version incrementation behavior.
- A tutorial on action behavior is available with examples and scenarios.
- Correspondence tables are available to help you visualize the format of the generated tags.
Please read the dedicated file for setup and project management.
Thanks for your interest! 👍