actions-set-product-version is a GitHub action that acts as a bridge between the product repository and our new CRT feature: automated version bumping. This action should be used in the build.yml to parse the version/VERSION file that lives in all product repositories.
The following describes what this action does:
- Allows for the static version string from the
version/VERSIONfile to be read by the new CRT workflow and automagically be bumped to the next version (whether it be a minor, or patch, or major version bump). - Outputs an error if there's no
VERSIONfile at the specified location - Outputs an error if there's no version string in the VERSION file
- Is able to parse
product_versionif it is1.3.0-alpha1as1.3.0(example: whenproduct_version = 1.3.0-alpha1,base_version = 1.3.0) - Is able to parse prerelease product versions such as
alpha1(exampleprerelease_product_version = alpha1) in the statement above.
| Input | Required | Default | Description |
|---|---|---|---|
checkout |
No | true |
Check out the code repository. Can be disabled if checkout is handled by the caller workflow. |
version-file |
No | version/VERSION |
Path to the VERSION file. For multi-product repos, specify the per-product VERSION file path (e.g., cmd/secrets-kv/VERSION). |
Note that the version/VERSION version should never contain metadata - only release version and prerelease information.
This action has four outputs from parsing the release/prerelease information:
product-version(full product version string: eg.1.0.0-dev)base-product-version(product version stripped of prerelease information: eg.1.0.0)prerelease-product-version(prerelease informationdev)minor-product-version(minor version number: eg.0)
This action should be implemented in product repository build.yml files. The action is intended to grab the version from the version file at the beginning of the build, then passes those versions (along with metadata, where necessary) to any workflow jobs that need version information.
jobs:
set-product-version:
runs-on: ubuntu-latest
outputs:
product-version: ${{ steps.set-product-version.outputs.product-version }}
base-product-version: ${{ steps.set-product-version.outputs.base-product-version }}
prerelease-product-version: ${{ steps.set-product-version.outputs.prerelease-product-version }}
steps:
- name: Set Product version
id: set-product-version
uses: hashicorp/actions-set-product-version@v2
# Reads from version/VERSION by defaultFor repositories that contain multiple products (e.g., vault-plugins), use the version-file input to specify the path to each product's VERSION file:
env:
PKG_NAME: "secrets-kv"
jobs:
set-product-version:
runs-on: ubuntu-latest
outputs:
product-version: ${{ steps.set-product-version.outputs.product-version }}
steps:
- uses: actions/checkout@v4
- name: Set Product version
id: set-product-version
uses: hashicorp/actions-set-product-version@v2
with:
version-file: cmd/${{ env.PKG_NAME }}/VERSION
# Reads from cmd/secrets-kv/VERSION
build:
needs: set-product-version
runs-on: ubuntu-latest
steps:
- run: echo "Building version ${{ needs.set-product-version.outputs.product-version }}"