This is a GitHub Action that provides the github-next-semantic-version tool/feature inside a GHA Workflow. This tool guesses the next semantic version from:
- existing git tags (read from a locally cloned git repository)
- and recently merged pull-requests labels (read from the GitHub API)
Unlinke plenty of "similar" tools, we don't use any "commit message parsing" here but only configurable PR labels.
- uses: actions/checkout@v4
with:
fetch-tags: true # we need to fetch tags to determine the latest version
fetch-depth: 0 # fetch-tags is not enough because of a GHA bug: https://github.com/actions/checkout/issues/1471
- id: version
uses: fabien-marty/github-next-semantic-version-action@v1
with:
github-token: ${{ github.token }} # Let's use the default value of the current workflow
repository: ${{ github.repository }} # Let's use the default value of the current workflow
repository-owner: ${{ github.repository_owner }} # Let's use the default value of the current workflow
- name: Use results
run: |
echo "Latest version is ${{ steps.version.outputs.latest-version }}"
echo "Next version is ${{ steps.version.outputs.next-version }}"
Note
In some configurations, you will also need to add this at the job level:
permissions:
pull-requests: read
contents: read
latest-version
: the latest version/tagnext-version
: the (computed) next version (thanks to github-next-semantic-version tool)
log-level
: Log Level (DEBUG
,INFO
orWARNING
), default toINFO
github-token
: GitHub Token (in most cases, you can use${{ github.token }}
as value)repository
: Full repository name (example:octocat/Hello-World
, in most cases, you want to use${{ github.repository }}
as value)repository-owner
: repository owner (example:octocat
), in most cases, you want to use${{ github.repository-owner }}
as value)major-labels
: coma separated list of PR labels to search for determining a major release (default to:major,breaking,Type: Major
)minor-labels
: coma separated list of PR labels to search for determining a minor release (default to:minor,Type: Minor, Type: Feature
)ignore-labels
: coma separated list of PR labels to search for ignoring a PR (default to:Type: Hidden
), can be useful withdont-increment-if-no-pr
optiondont-increment-if-no-pr
: Do not increment if no PR found (or only ignored PRs), default tofalse
, can be useful to determine automatically if a release is neededconsider-also-non-merged-prs
: If set totrue
(default tofalse
), consider also "non merged" PRs to compute the next versiontag-regex
: If set, filter tags with the given regex