depth #10
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: Branch check | ||
on: [ push ] | ||
jobs: | ||
check: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# So that we get the branch for `base_ref`. | ||
fetch-depth: 0 | ||
- name: Check branch | ||
run: | | ||
import os | ||
import re | ||
import subprocess | ||
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"] ), | ||
int( versions["gafferMinorVersion"] ), | ||
int( versions["gafferPatchVersion"] ), | ||
] | ||
mergedVersion = version() | ||
print( mergedVersion ) | ||
sourceBranch = "main" #os.environ["GITHUB_HEAD_REF"] | ||
subprocess.check_call( [ "git", "checkout", sourceBranch ] ) | ||
sourceVersion = version() | ||
if sourceVersion != mergedVersion : | ||
sys.stderr.write( | ||
"Source branch version {} does not match merged version {}\n".format( | ||
sourceVersion, mergedVersion | ||
) | ||
) | ||
sys.exit( 1 ) | ||
print( os.environ ) | ||
shell: python |