From 2297ae1a22b645a6204fbc6d9e44625f880813ce Mon Sep 17 00:00:00 2001 From: Gennadi McKelvey Date: Thu, 21 Nov 2024 22:56:50 +0100 Subject: [PATCH] fix - build-script (#93) * update build * fix missing version --- build-deptrac.sh | 15 ++++++++++----- composer.json | 3 +-- scoper.inc.php | 23 ++++++++++++++++++++++- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/build-deptrac.sh b/build-deptrac.sh index ab4c24b0..c29c1d17 100644 --- a/build-deptrac.sh +++ b/build-deptrac.sh @@ -4,9 +4,14 @@ DEPTRAC_DIR="${DEPTRAC_DIR:-../deptrac-scoped}" BUILD_DIR=build BUILD_TMP=${BUILD_DIR}/deptrac-build PHP='docker compose exec -u 1000 deptrac php -d memory_limit=-1' +CONTAINER='docker compose exec -u 1000 deptrac bash' SCOPER=$BUILD_DIR/php-scoper.phar BOX=$BUILD_DIR/box.phar +echo $DEPTRAC_DIR +echo $BUILD_DIR +echo $BUILD_TMP + info() { MESSAGE=$1; @@ -26,19 +31,19 @@ $PHP $SCOPER add-prefix --force --config scoper.inc.php --working-dir . --output $PHP $BOX compile # info "sign phar" -gpg --detach-sign --armor --local-user ${USER} --output $BUILD_TMP/deptrac.phar.asc $BUILD_TMP/deptrac.phar +gpg --detach-sign --armor --local-user 974E9033414D7F2BC9FE1E6AD4F06E96D1BD037B --output $BUILD_TMP/deptrac.phar.asc $BUILD_TMP/deptrac.phar gpg --verify $BUILD_TMP/deptrac.phar.asc $BUILD_TMP/deptrac.phar info "Dump Composer Autoloader" $PHP /usr/bin/composer dump-autoload --working-dir $BUILD_TMP -a --no-dev info "Copy package templates" -cp -r $BUILD_DIR/template/* *.md mkdocs.yml docs -t $BUILD_TMP -cp -r $BUILD_DIR/template/.* -t $BUILD_TMP +$CONTAINER cp -rv $BUILD_DIR/template/* *.md mkdocs.yml docs -t $BUILD_TMP +$CONTAINER cp -rv $BUILD_DIR/template/.github -t $BUILD_TMP +$CONTAINER cp -rv $BUILD_DIR/template/.gitignore -t $BUILD_TMP info "Copy build into deptrac distrubtion repository" -cp -r $BUILD_TMP/* $DEPTRAC_DIR -cp -rv $BUILD_TMP/.* $DEPTRAC_DIR +cp -rv $BUILD_TMP/* $DEPTRAC_DIR # info "Git commit changes" # echo "Update $(date)" > git_commit_message.txt diff --git a/composer.json b/composer.json index 12975997..85d485b6 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,7 @@ }, { "name": "Denis Brumann", - "email": "denis.brumann@qossmic.com", - "role": "maintainer" + "email": "denis.brumann@qossmic.com" } ], "bin": [ diff --git a/scoper.inc.php b/scoper.inc.php index 2fc66bc9..899580da 100644 --- a/scoper.inc.php +++ b/scoper.inc.php @@ -25,7 +25,28 @@ 'test', ])->notName('/.*\\.(xml|md|dist|neon|zip)|Makefile|composer\\.json|composer\\.lock/'), ], - 'patchers' => [], + 'patchers' => [ + static function (string $filePath, string $prefix, string $content): string { + if (str_contains($filePath, 'src/Supportive/Console/Application.php')) { + // resolve current tag + exec('git tag --points-at', $output, $result_code); + + if (0 !== $result_code) { + throw new InvalidArgumentException('Ensure to run compile from composer git repository clone and that git binary is available.'); + } + + if ([] !== $output) { + $tag = $output[0]; + + if ('' !== $tag) { + return str_replace('@git-version@', $tag, $content); + } + } + } + + return $content; + }, + ], 'tag-declarations-as-internal' => false, 'exclude-files' => array_map( static function ($file) {