Skip to content

villoro/vhooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vhooks GitHub Actions

GitHub release (latest by date)

This repository contains two reusable GitHub Actions:

  1. 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.
  2. Tag Version – Automatically tags a commit with the version from a specified file when selected paths change in the main branch.

🚀 Check Package Version

Usage

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'

🛠️ Inputs

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: ['**']

✅ Expected Behavior

  • 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.

🚀 Tag Version

Usage

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'

🛠️ Inputs

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)

✅ Expected Behavior

  • 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.

🔗 Related Links

About

Github actions hooks

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages