This GitHub action calculates the next semantic version (major.minor.patch) based on the latest Git tag.
- name: Get next version
id: get_version
uses: danielboxer/next-version-action@v1
with:
# which part of the version to increment (major, minor, patch)
increment: patch
# optional: manually set a version instead of auto-incrementing
version: null
# optional: add "v" prefix to version
use_v_prefix: null
- name: Create release
uses: softprops/action-gh-release@v2
with:
# use the new version generated by this action
tag_name: ${{ steps.get_version.outputs.new_version }}This action can be combined with workflow_dispatch inputs to create a GUI for automating releases more easily:
on:
workflow_dispatch:
inputs:
increment:
description: "Which part of the version to increment"
type: choice
options:
- major
- minor
- patch
default: "patch"
required: true
version:
description: "Override version increment"
required: false
...
steps:
- name: Get Next Version
id: get_version
uses: danielboxer/next-version-action@v1
with:
increment: ${{ github.event.inputs.increment }}
version: ${{ github.event.inputs.version }}
use_v_prefix: true- If no previous tag exists, defaults to 0.1.0
