This repository contains two reusable GitHub Actions:
- Check Package Version – Validates that the version in a specified file (e.g.,
pyproject.toml,version.json,config.yml) has been incremented before merging a pull request. - Tag Version – Automatically tags a commit with the version from a specified file when selected paths change in the
mainbranch.
Add this workflow to .github/workflows/check_version.yml:
name: Check Version
on:
pull_request:
branches:
- main
jobs:
check_version:
runs-on: ubuntu-latest
steps:
- uses: villoro/vhooks/[email protected]
with:
branch: "main" # Branch to compare against
file: "pyproject.toml" # File to extract the version from
path: "project/version" # Path inside the file
filters: |
code:
- 'src/ecs_northius/**'
- 'pyproject.toml'| Input | Description | Required | Default |
|---|---|---|---|
repository |
Repository to check the version in. | ✅ Yes | ${{ github.repository }} |
ref |
Branch or commit ref to evaluate. | ✅ Yes | ${{ github.ref }} |
branch |
Target branch to compare against. | ❌ No | main |
file |
File containing the version (supports .toml, .json, .yml). |
❌ No | pyproject.toml |
path |
Path inside the file to extract the version. | ❌ No | project/version |
filters |
YAML configuration for dorny/paths-filter. Must define a code key. |
❌ No | code: ['**'] |
- Runs only if specified paths change.
- Fails the PR if the version is missing, unchanged, or skips versions.
- Passes when the version has been correctly incremented.
Add this workflow to .github/workflows/tag_version.yml:
name: Tag Version
on:
push:
branches:
- main
permissions:
contents: write
jobs:
tag_version:
runs-on: ubuntu-latest
steps:
- uses: villoro/vhooks/[email protected]
with:
file: "pyproject.toml" # File containing the version
path: "project/version" # Path inside the file
filters: |
code:
- 'src/ecs_northius/**'
- 'pyproject.toml'| Input | Description | Required | Default |
|---|---|---|---|
branch |
Branch to check version from. | ❌ No | main |
file |
File to extract the version from (supports .toml, .json, .yml). |
❌ No | pyproject.toml |
path |
Path inside the file to extract the version. | ❌ No | project/version |
filters |
YAML configuration for dorny/paths-filter. Must define a code key. |
❌ No | code: ['**'] |
tag-prefix |
Optional prefix to prepend to the tag (e.g. v creates v1.2.3). |
❌ No | (empty) |
- Runs only when watched paths change.
- Extracts version from the specified file and path.
- Creates a Git tag if it doesn’t already exist.
- Skips tagging if the tag is already present.