This helper Github Action outputs several semantic versioning variables based on the git branch/tag that is building. It assumes that you are using the twgit git flow with conventions of:
- Released tags:
vx.x.x
- Upcoming releases:
release-x.x.x
(where x.x.x
is your release number)
build_number_start
: Allows you to bump the Github build number by some predermined value - useful for migrating from another build system and wanting to resume from where you left off (or higher). Not required, defaults to0
semver_release_string
: The full semver release string. e.g.1.0.0+000598
or2.1.0-SNAPSHOT4994
.semver_release_number
: Just the release number part, e.g.1.0.0
or2.1.0
semver_is_stable
:true
orfalse
, whether or not this release is a stable released version or an upcoming snapshot release.semver_is_snapshot
:true
orfalse
, whether or not this release is an upcoming snapshot release or a stable released version.
# .github/workflows/publish.yml
name: Publish
# you may wish to trigger this for other specifics, this is an example
on:
push:
tags:
- v*
branches:
- release-*
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- id: releasenumber
uses: pixl8/github-action-twgit-release-version-generator@v1
with:
build_number_start: 5609
# then can use ${{ steps.releasenumber.outputs.variable_name }} in
# your step env vars, e.g.
- name: my-next-step
env:
VERSION_NUMBER: ${{ steps.releasenumber.outputs.semver_release_string }}