Skip to content

stfc/check-version-action

Repository files navigation

Check Version

GitHub Actions Workflow Status GitHub Actions Workflow Status GitHub Actions Workflow Status codecov

If you have a software project that uses a version.txt file then you can use this action to make sure the version is updated when pull requests are made.

This action will compare the version.txt file on the feature branch to the main branch.

Projects using this action in their CI must use one of the below labels matching the version change.

major | minor | bug | patch

If you project has a docker-compose.yaml file, you can also check that the first image version matches the version.txt

The comparison follows the PEP 440 Version Identification and Dependency Specification.

More detailed information about the versions can be found here

Usage

Notes:

As of October 2024 GitHub actions using Docker Containers can only be run on GitHub runners using a Linux operating system.
Read here for details: Link to GitHub docs

If you are making a change which should not affect the version such as README or CI changes. You can label the pull request with documentation or workflow and the version checks will be skipped.

- name: Checkout main
  uses: actions/checkout@v4
  with:
    # Change to "master" if needed
    ref: 'main'
    # Do not change the path here
    path: 'main'

- name: Checkout current working branch
  uses: actions/checkout@v4
  with:
    # Do not change the path here
    path: 'branch'
    
- name: Compare versions
  # Don't run on main otherwise it compares main with main
  if: ${{ github.ref != 'refs/heads/main' }} 
  id: version_comparison
  uses: stfc/check-version-action@main
  with:
    labels: ${{ toJSON(github.event.pull_request.labels.*.name) }}
    # Path to version file from project root
    app_version_path: "version.txt"
    # Optional: to check if Docker compose image version matches app version
    docker_compose_path: "docker-compose.yaml"

About

GitHub action to check version.txt files are updated correctly.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors