This Github action will help increment a given semantic version. It is inspired by the kotlin-semver implementation.
uses: kurt-ikhokha/gha-semantic-version@v1.0.1
with:
version-name: '3.4.0' #required if version-file not provided
version-name-postfix: 'alpha' #optional postfix to append to the version name
version-code: 4196 #required if version-file not provided
update-type: 'patch'. # major, minor, patch, pre-release, release
version-file: '<path/to/version.properties file>' # required if version-name and version-code are not provided
version-code-key: 'version.code' #required if version-file is provided and is the key name for the version code in the provided properties file
version-name-key: 'version.name' #required if version-file is provided and is the key name for the version name in the provided properties fileThe version.properties file should be in the following format:
version.name=3.4.0 #required. If `version-name-key` is provided, then instead of `version.name`, use the value of `version-name-key`
version.code=4196 #required. If `version-code-key` is provided, then instead of `version.code`, use the value of `version-code-key`Examples
# patch version update
- name: 'PATCH version update'
uses: kurt-ikhokha/gha-semantic-version@v1.0.1
id: patch
with:
version-name: '1.0.0'
version-code: 1
update-type: 'patch'
- name: 'Get Patched version'
run: |
echo "update"
echo "Version name: ${{ steps.patch.outputs.new-version-name }}" #1.0.1
echo "Version code: ${{ steps.patch.outputs.new-version-code }}" #2
# minor version update
- name: 'MINOR version update'
uses: kurt-ikhokha/gha-semantic-version@v1.0.1
id: minor
with:
version-name: '1.0.0'
version-code: 1
update-type: 'minor'
- name: 'Get Minored version'
run: |
echo "update"
echo "Version name: ${{ steps.minor.outputs.new-version-name }}" #1.1.0
echo "Version code: ${{ steps.minor.outputs.new-version-code }}" #2
# major version update
- name: 'MAJOR version update'
uses: kurt-ikhokha/gha-semantic-version@v1.0.1
id: major
with:
version-name: '1.0.0'
version-code: 1
update-type: 'major'
- name: 'Get Majored version'
run: |
echo "update"
echo "Version name: ${{ steps.major.outputs.new-version-name }}" #2.0.0
echo "Version code: ${{ steps.major.outputs.new-version-code }}" #2
# official version for a pre-release
- name: 'PRE-RELEASE version update'
uses: kurt-ikhokha/gha-semantic-version@v1.0.1
id: build
with:
version-name: '1.0.0-alpha.1'
version-code: 1
update-type: 'pre-release'
- name: 'Get Builded version'
run: |
echo "update"
echo "Version name: ${{ steps.build.outputs.new-version-name }}" #1.0.0-alpha.2
echo "Version code: ${{ steps.build.outputs.new-version-code }}" #2
# official version for a pre-release
- name: 'RELEASE version update'
uses: kurt-ikhokha/gha-semantic-version@v1.0.1
id: build
with:
version-name: '1.0.0-alpha.01'
version-code: 1
update-type: 'release'
- name: 'Get Builded version'
run: |
echo "update"
echo "Version name: ${{ steps.build.outputs.new-version-name }}" #1.0.0
echo "Version code: ${{ steps.build.outputs.new-version-code }}" #1First, you'll need to have a reasonably modern version of
nodehandy. This won't work with versions older than 9, for instance.
Install the dependencies
$ npm installBuild the typescript and package it for distribution
$ npm run build && npm run packageRun the tests ✔️
$ npm test
PASS __tests__/semantic-version.test.ts
version updates without properties file
✓ can update a versions patch number (1 ms)
✓ can update versions minor number
✓ can update versions major number
✓ can update a version build
...