[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Command line tool to check proper version strings 4 * 5 * Expects a tag as first argument. Used in release action to ensure proper formats 6 * in VERSION file and git tag. 7 */ 8 9 if (!isset($argv[1])) { 10 echo "::error::No git tag given, this action should not have run\n"; 11 exit(1); 12 } 13 $TAG = $argv[1]; 14 $TAG = str_replace('refs/tags/', '', $TAG); 15 16 if (!file_exists(__DIR__ . '/../VERSION')) { 17 echo "::error::No VERSION file found\n"; 18 exit(1); 19 } 20 $FILE = trim(file_get_contents(__DIR__ . '/../VERSION')); 21 $FILE = explode(' ', $FILE)[0]; 22 23 24 if(!preg_match('/^release_(stable|candidate)_((\d{4})-(\d{2})-(\d{2})([a-z])?)$/', $TAG, $m)) { 25 echo "::error::Git tag does not match expected format: $TAG\n"; 26 exit(1); 27 } else { 28 $TAGTYPE = $m[1]; 29 $TAGVERSION = $m[2]; 30 } 31 32 if(!preg_match('/^(rc)?((\d{4})-(\d{2})-(\d{2})([a-z])?)$/', $FILE, $m)) { 33 echo "::error::VERSION file does not match expected format: $FILE\n"; 34 exit(1); 35 } else { 36 $FILETYPE = $m[1] == 'rc' ? 'candidate' : 'stable'; 37 $FILEVERSION = $m[2]; 38 $TGZVERSION = $m[0]; 39 } 40 41 if($TAGTYPE !== $FILETYPE) { 42 echo "::error::Type of release mismatches between git tag and VERSION file: $TAGTYPE <-> $FILETYPE\n"; 43 exit(1); 44 } 45 46 if($TAGVERSION !== $FILEVERSION) { 47 echo "::error::Version date mismatches between git tag and VERSION file: $TAGVERSION <-> $FILEVERSION\n"; 48 exit(1); 49 } 50 51 // still here? all good, export Version 52 echo "::set-output name=VERSION::$TGZVERSION\n";
title
Description
Body
title
Description
Body
title
Description
Body
title
Body