Skip to content

Commit

Permalink
use GITHUB_ENV for setting environment variable COMPOSER_ROOT_VERSION
Browse files Browse the repository at this point in the history
copying approach from laminas/laminas-cache-storage-adapter-blackhole

Signed-off-by: Dennis Riehle <webmaster@riehle-web.com>
  • Loading branch information
driehle committed Jan 13, 2025
1 parent 50e53d3 commit 883eff2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
31 changes: 31 additions & 0 deletions .laminas-ci/composer-root-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash -l

if [[ -z "${GITHUB_BASE_REF}" ]]; then
echo "Environment variable \"GITHUB_BASE_REF\" does not exist."

exit 0
fi

BRANCH_REGEX="[0-9]+\.[0-9]+\.x"

if ! [[ "${GITHUB_BASE_REF}" =~ ${BRANCH_REGEX} ]]; then
echo "Environment variable \"GITHUB_BASE_REF\" does not match expectations."
echo "Must match ${BRANCH_REGEX}";

exit 0
fi

export COMPOSER_ROOT_VERSION=$(echo ${GITHUB_BASE_REF} | sed 's/\.x/\.99/g')

echo "Determined composer root version as \"${COMPOSER_ROOT_VERSION}\"."

if [[ true = "${GITHUB_ACTIONS}" ]]; then
echo "Setting COMPOSER_ROOT_VERSION environment variable to \"${COMPOSER_ROOT_VERSION}\"."
if [ ! -w "${GITHUB_ENV}" ]; then
echo "Missing GITHUB_ENV environment variable. Cannot store COMPOSER_ROOT_VERSION to be available within the current check."
exit 1
fi
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> "${GITHUB_ENV}"
fi

return
16 changes: 5 additions & 11 deletions .laminas-ci/pre-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@

WORKING_DIRECTORY=$2
JOB=$3
PHP_VERSION=$(php -nr "echo PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION;")
PHP_VERSION=$(echo "${JOB}" | jq -r '.php')

if [ ! -z "$GITHUB_BASE_REF" ] && [[ "$GITHUB_BASE_REF" =~ ^[0-9]+\.[0-9] ]]; then
readarray -td. TARGET_BRANCH_VERSION_PARTS <<<"${GITHUB_BASE_REF}.";
unset 'TARGET_BRANCH_VERSION_PARTS[-1]';
declare -a TARGET_BRANCH_VERSION_PARTS
MAJOR_OF_TARGET_BRANCH=${TARGET_BRANCH_VERSION_PARTS[0]}
MINOR_OF_TARGET_BRANCH=${TARGET_BRANCH_VERSION_PARTS[1]}
${WORKING_DIRECTORY}/.laminas-ci/install-apcu-extension-via-pecl.sh "${PHP_VERSION}" || exit 1
${WORKING_DIRECTORY}/.laminas-ci/composer-root-version.sh || exit 1

export COMPOSER_ROOT_VERSION="${MAJOR_OF_TARGET_BRANCH}.${MINOR_OF_TARGET_BRANCH}.99"
echo "Exported COMPOSER_ROOT_VERSION as ${COMPOSER_ROOT_VERISON}"
fi
echo "Composer Root Version: $COMPOSER_ROOT_VERSION"

${WORKING_DIRECTORY}/.laminas-ci/install-apcu-extension-via-pecl.sh "${PHP_VERSION}" || exit 1
return
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"version": "3.13.0",
"extra": {
"laminas": {
"component": "Laminas\\Cache",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 883eff2

Please sign in to comment.