Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Version check | |
on: [ push ] | |
jobs: | |
check: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# So that we get the branch for `GITHUB_HEAD_REF`. | |
fetch-depth: 0 | |
- name: Check version | |
run: | | |
import os | |
import re | |
import subprocess | |
import sys | |
# Parses version number from the SConstruct file. | |
def version() : | |
versions = {} | |
versionRe = re.compile( r"^(gaffer.*Version.*) = (\S+)" ) | |
with open( "SConstruct" ) as sconstruct : | |
for line in sconstruct.readlines() : | |
versionMatch = versionRe.match( line ) | |
if versionMatch : | |
versions[versionMatch.group( 1 )] = versionMatch.group( 2 ).strip( "'\"" ) | |
return [ | |
int( versions["gafferMilestoneVersion"] ), | |
int( versions["gafferMajorVersion"] ), | |
] | |
# Check that versions match between source and target branches, to avoid | |
# common mistake of targeting a PR to `main` rather than a maintenance branch. | |
# | |
# > Note : We compare the source version to the merged version rather than the | |
# > version from the target branch itself, to allow a PR to change version number | |
# > if necessary. That will just be subject to the usual human review process. | |
mergeVersion = version() | |
subprocess.check_call( [ "git", "checkout", "1.4_maintenance" ] ) #os.environ["GITHUB_HEAD_REF"] ] ) | |
sourceVersion = version() | |
if sourceVersion != mergeVersion : | |
sys.stderr.write( | |
"ERROR : Source version {} does not match target version {}. Did you choose the wrong target branch?\n".format( | |
".".join( str( v ) for v in sourceVersion ), | |
".".join( str( v ) for v in mergeVersion ) | |
) | |
) | |
sys.exit( 1 ) | |
shell: python |