This action sets the version based on either the current commit hash or tag. The result can optionally be written to a file directly.
Note: Tags MUST be in one of the following formats or this action will fail: vMAJOR.MINOR.PATCH
or vMAJOR.MINOR.PATCH-identifier
.
Required Source for the version, either commit
or tag
. Default commit
.
File path to write the version to, relative to the workspace.
Version placeholder to replace with the version if file_path
is set. Default 0.0.0+development
.
The version.
This example uses the version variable directly in the docker build
command.
jobs:
build:
- name: Checkout
uses: actions/checkout@v2
- name: Set version
uses: weareyipyip/set-version-action@v2
id: set-version
with:
source: tag
- name: Build Docker image
run: 'docker build -t some-image:${{ steps.set-version.outputs.version }}'
This example directly replaces the version placeholder in package.json
with the parsed version. The string 0.0.0+development
will be replaced in the specified target_file
by default.
jobs:
build:
- name: Checkout
uses: actions/checkout@v2
- name: Set version
uses: weareyipyip/set-version-action@v2
with:
source: tag
file_path: package.json
- name: Build Node package
run: 'npm build'
This example directly replaces the version placeholder in package.json
with the parsed version. The string 0.0.0+development
will be replaced in the specified target_file
by default. The commit hash can be used for builds that aren't tagged, e.g. automated test builds.
jobs:
build:
- name: Checkout
uses: actions/checkout@v2
- name: Set version
uses: weareyipyip/set-version-action@v2
with:
source: commit
file_path: package.json
- name: Build Node package
run: 'npm build'